feat: introduce local nv21 skeleton

Introduce nv21 skeleton for local testing:

- Use local go-state-types with actor_version_checklist changes: https://github.com/filecoin-project/go-state-types/blob/master/actors_version_checklist.md
- Imports mock v12-actors bundle
- Define upgrade heights
- Generate adapters
- Add upgrade schedule and migration
- Add actorstype to the NewActorRegistry in /chain/consensus/computestate.go
- Add upgrade field to api/types.go/ForkUpgradeParams
- Add upgrade to node/impl/full/state.go
- Add network version to chain/state/statetree.go
- make jen
- make docsgen-cli
This commit is contained in:
Phi 2023-07-07 11:56:30 +02:00
parent 7bb1f98ac6
commit 8b5da86727
55 changed files with 3064 additions and 91 deletions

View File

@ -339,6 +339,7 @@ type ForkUpgradeParams struct {
UpgradeHyggeHeight abi.ChainEpoch
UpgradeLightningHeight abi.ChainEpoch
UpgradeThunderHeight abi.ChainEpoch
UpgradeWatermelonHeight abi.ChainEpoch
}
type NonceMapType map[address.Address]uint64

BIN
build/actors/v12.tar.zst Normal file

Binary file not shown.

View File

@ -74,6 +74,29 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet
}, {
Network: "butterflynet",
Version: 11,
ManifestCid: MustParseCid("bafy2bzaceaiy4dsxxus5xp5n5i4tjzkb7sc54mjz7qnk2efhgmsrobjesxnza"),
Actors: map[string]cid.Cid{
"account": MustParseCid("bafk2bzacecfdqb7p3jakhaa3cqnzpt7hxmhghrbxvafsylqno3febx55fnidw"),
"cron": MustParseCid("bafk2bzaceavmqu2qihgbe3xdaotgypuzvdpiifnm7ll6rolks2u4lac6voosk"),
"datacap": MustParseCid("bafk2bzacealtvh65rzb34fmyzw4m2np2htnio4w3pn4alzqovwxkdbf23dvpo"),
"eam": MustParseCid("bafk2bzacedko6hcjmwpuwgma5pb4gr2wgyvregk3nqqjxit7dv4es6vh5cjoc"),
"ethaccount": MustParseCid("bafk2bzacedhcei2xnr34poxr4xziypm2obqlibke4cs2cjfnr3sz6nf6h7fyy"),
"evm": MustParseCid("bafk2bzacebn5lwxboiikhz67ajwa34v2lc4qevnhpwdnipbmrnutkvrrqkb46"),
"init": MustParseCid("bafk2bzacea6vw4esh5tg7mprv5jkbx5xcyilcy4vvf64lss32mjyuvv2mh5ng"),
"multisig": MustParseCid("bafk2bzacedq2afnwcfipay5twv5mgzjoio5bbjvyo4yqchdwqcr7wrareyx54"),
"paymentchannel": MustParseCid("bafk2bzacebbsvr7i7mqmaadyjibe5wxnv7bwvvec2wlgknuwda6ep45amnd5w"),
"placeholder": MustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"),
"reward": MustParseCid("bafk2bzaceafuh6idvaqqkj353vs4qdl42tcmvnymewu5zf4rq2nruxdyunses"),
"storagemarket": MustParseCid("bafk2bzaceb7bx4honi3byjllpdk6fea32dpu3vqvil3okodybdk5m3erlnwjw"),
"storageminer": MustParseCid("bafk2bzacebxjhofdr3sb2uhy2ky2vcijh4nhmwkh5xijtbgk6dzkknji2kn7a"),
"storagepower": MustParseCid("bafk2bzaceabskmmkas6njbowols7t4ib3bipa5abpomk3jtgfwojtzd7mjzfm"),
"system": MustParseCid("bafk2bzacedtuh7cht3fud7fb4avl4g2zbz57lc4ohiaufpaex6dkmdokn5rgo"),
"verifiedregistry": MustParseCid("bafk2bzaceb37hxeuoo5rgf6ansrdl2ykm5v5zp6kireubn4orcopr67jbxv6k"),
},
}, {
Network: "butterflynet",
Version: 12,
BundleGitTag: "v11.0.0",
ManifestCid: MustParseCid("bafy2bzaceaiy4dsxxus5xp5n5i4tjzkb7sc54mjz7qnk2efhgmsrobjesxnza"),
Actors: map[string]cid.Cid{
@ -157,7 +180,7 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet
}, {
Network: "calibrationnet",
Version: 11,
BundleGitTag: "v11.0.0-rc2",
ManifestCid: MustParseCid("bafy2bzacedhuowetjy2h4cxnijz2l64h4mzpk5m256oywp4evarpono3cjhco"),
Actors: map[string]cid.Cid{
"account": MustParseCid("bafk2bzacebor5mnjnsav34cmm5pcd3dy4wubbv4wtcrvba7depy3sct7ie4sy"),
@ -177,6 +200,29 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet
"system": MustParseCid("bafk2bzacedqvik2n3phnj3cni3h2k5mtvz43nyq7mdmv7k7euejysvajywdug"),
"verifiedregistry": MustParseCid("bafk2bzaceceoo5jlom2zweh7kpye2vkj33wgqnkjshlsw2neemqkfg5g2rmvg"),
},
}, {
Network: "calibrationnet",
Version: 12,
BundleGitTag: "v11.0.0",
ManifestCid: MustParseCid("bafy2bzacec5fl7crmxyw234qsmijvffhssgqwuphyaejulbryhel2pxxrxgey"),
Actors: map[string]cid.Cid{
"account": MustParseCid("bafk2bzacecrjovyiuh4jryepy4pxddzqjyrg2hfinxzbv37bpzlci54r5mkr6"),
"cron": MustParseCid("bafk2bzacedy76woxmtalmsuaji4kog6wmq4h2kcgcyv5wpxbdz7f2ls2tjjmw"),
"datacap": MustParseCid("bafk2bzacec2inqddxpfm3rufwqr752d2ok3ve4cxfhmloyosy6rj2krtkpwus"),
"eam": MustParseCid("bafk2bzacea6sxno66egkqz5rqjq4e22obkeblxl7e3funjifljuinmrc2ztzg"),
"ethaccount": MustParseCid("bafk2bzacecdsvs7xm3ncm66lsjqh65uzhr3rmu3dlux7qzdgpg737r4kslhxm"),
"evm": MustParseCid("bafk2bzaceaz3b66m2znt27clmbp2zi5jsobw6g2x6fiezynyijgtkehgqhq3a"),
"init": MustParseCid("bafk2bzacecdrw7uedx456hnowtyyhm63mkekdlkh3vmlhvqlya6pn6pokiq5y"),
"multisig": MustParseCid("bafk2bzaceaxyxvmng5cel5huzy5nezscm34s7wuzn2fhndexurs3xjtp7xg5i"),
"paymentchannel": MustParseCid("bafk2bzacedrmyc4c6u6ipdo7hwaagx3urr47r4pw6lwv257wqbj6roumwfvky"),
"placeholder": MustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"),
"reward": MustParseCid("bafk2bzacecq3bhrkatwash5zhy2275ksaj3criqb6rox5e3hsyvz7mrl2jh3o"),
"storagemarket": MustParseCid("bafk2bzacedswrpkbh7jmttskllbblym7oj2ynxp7bxtj2fpbxsx55mraog6sc"),
"storageminer": MustParseCid("bafk2bzacecki6ckm7gf4uje3fxvw6x5f77ukaqctvcsfha6oaecvl67veh3sg"),
"storagepower": MustParseCid("bafk2bzacecjcvxwibkgpufeah33gfd2jzlqjx5rn2pguvvch2squon23u6kne"),
"system": MustParseCid("bafk2bzaceavvlgqbcwhy3c24aa24z23wcbzggmb66gj7x5if7o3fbvddaocc4"),
"verifiedregistry": MustParseCid("bafk2bzacedmxdtnpy2mc63b6bi2h4vp4dfc6hxjckqnwaxyijgkpmangygcmk"),
},
}, {
Network: "caterpillarnet",
Version: 8,
@ -249,6 +295,29 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet
}, {
Network: "caterpillarnet",
Version: 11,
ManifestCid: MustParseCid("bafy2bzacebexc2jgzwr5ngn6jdnkwdqwwmcapajuypdgvopoe6bnvp4yxm4o2"),
Actors: map[string]cid.Cid{
"account": MustParseCid("bafk2bzaceanjiq5m3feytue5m7hhxfkob2ofg2greoct5tr77reuhrjglo66g"),
"cron": MustParseCid("bafk2bzaceavgd5qj6n744tukhdrvxejygzs3jnlizmcvjsdnxkgiimrd5jrys"),
"datacap": MustParseCid("bafk2bzacedmdywxwrzop2gmf4ys5stydlmvbe35j3nyr2efmf273briksuvse"),
"eam": MustParseCid("bafk2bzacec7qo7s72li7tqysllstlrxxm2dhfqv2w32pytel2e775cki4ozqm"),
"ethaccount": MustParseCid("bafk2bzaceaygtkliu26ubb7ivljrvaeesp5sbjlis5okzl35ishxioa2tlx4w"),
"evm": MustParseCid("bafk2bzacebo7iqzy2ophz4f3civzwlltec7q5fut7kmtfckr6vy33r6ic5eqe"),
"init": MustParseCid("bafk2bzaceb7uzzlsquqwrqhb2vpbvk3jgr4wp5i3smu2splnag2v5sppdehns"),
"multisig": MustParseCid("bafk2bzacebwibfqrytobl4pjtny244zkmfoomazbap3r5gddjryckx5js4csi"),
"paymentchannel": MustParseCid("bafk2bzacecuaa5esuxpouigxoamyl5gire2qqqhvyhewsig2x2j73f6ksh7go"),
"placeholder": MustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"),
"reward": MustParseCid("bafk2bzaced4xxqhv63njf2ibvsqshlwikafctxev7aho5lgsfxyt2javjwvtw"),
"storagemarket": MustParseCid("bafk2bzacedwtx3xokqmbgkgkoqkdt6lam4ymdjb3eznlbtec5wcrtx74l2bpc"),
"storageminer": MustParseCid("bafk2bzacebbbe4sdo3xxkez7x7lkl6j46w34vx7eg7xswmdzhp7moa44p3wjg"),
"storagepower": MustParseCid("bafk2bzacedfgz6n24tjsor4pcayomim2f5f3a3fgyatmjgwxxeejna7okndda"),
"system": MustParseCid("bafk2bzacebxfzeom3d7ahcz2n2nlwp7ncv767bdbbrisugks4l6v7lcu2tmyg"),
"verifiedregistry": MustParseCid("bafk2bzacedaws3or3twy45ltcxucgvqijsje4x675ph6vup2w35smlfneamno"),
},
}, {
Network: "caterpillarnet",
Version: 12,
BundleGitTag: "v11.0.0",
ManifestCid: MustParseCid("bafy2bzacebexc2jgzwr5ngn6jdnkwdqwwmcapajuypdgvopoe6bnvp4yxm4o2"),
Actors: map[string]cid.Cid{
@ -332,6 +401,29 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet
}, {
Network: "devnet",
Version: 11,
ManifestCid: MustParseCid("bafy2bzaceay35go4xbjb45km6o46e5bib3bi46panhovcbedrynzwmm3drr4i"),
Actors: map[string]cid.Cid{
"account": MustParseCid("bafk2bzacecf2pprkbdlpm4e2xz3ufunxtgrgyh2ie3stuqiyhibsvdze7kvri"),
"cron": MustParseCid("bafk2bzaceasr5d2skowvzv5mzsyak6waqrgc46ewj6rzbapkfi5woom6n6bwa"),
"datacap": MustParseCid("bafk2bzaceaqd77gptubupda7rp7daxkxbkzwc253dxhiyoezxvj2tljmkgpny"),
"eam": MustParseCid("bafk2bzacedve6p4ye6zxydjbfs4ode5r2equ7rqzpyltujsq2lu6wyxnijfx4"),
"ethaccount": MustParseCid("bafk2bzacea25xfsxwew3h2crer6jlb4c5vwu2gtch2jh73ocuxjhupenyrugy"),
"evm": MustParseCid("bafk2bzacece5hivtkmi757lyfahgti7xuqgofodb2u65pxgf6oizfwiiwlcsi"),
"init": MustParseCid("bafk2bzacecxnr5y7qifzdqqiwfbjxv2yr7lbkcyu3e2mf5zjdncteupxdlquu"),
"multisig": MustParseCid("bafk2bzaceayap4k4u3lbysaeeixct5fvhmafy3fa5eagvdpk3i4a7ubfdpobe"),
"paymentchannel": MustParseCid("bafk2bzaceafgrz5wepbein35gie7rnsu7zttxvgllgdneuefmmy4j5izydtza"),
"placeholder": MustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"),
"reward": MustParseCid("bafk2bzacedwbtfqlx47fdkxjrb5mwiatheci44x3zkpx33smybc2cme23ymuo"),
"storagemarket": MustParseCid("bafk2bzaceaj74fmooaf3gj3ebwon64ky7hhdh7kytdr3agclqfrqzmpzykh7g"),
"storageminer": MustParseCid("bafk2bzacedb7bokkzzs7hnbhivp74pgcpermuy7j6b3ncodylksukkxtnn7ze"),
"storagepower": MustParseCid("bafk2bzacedilnkegizkxz3nuutib4d4wwlk4bkla22loepia2h53yf4hysmq6"),
"system": MustParseCid("bafk2bzacedpyoncjbl4oxkjm5e77ngvpy2xfajjc4myfsv2vltvzxioattlu2"),
"verifiedregistry": MustParseCid("bafk2bzacebdqi5tr5pjnem5nylg2zbqcugvi7oxi35bhnrfudx4y4ufhlit2k"),
},
}, {
Network: "devnet",
Version: 12,
BundleGitTag: "v11.0.0",
ManifestCid: MustParseCid("bafy2bzaceay35go4xbjb45km6o46e5bib3bi46panhovcbedrynzwmm3drr4i"),
Actors: map[string]cid.Cid{
@ -438,6 +530,29 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet
}, {
Network: "mainnet",
Version: 11,
ManifestCid: MustParseCid("bafy2bzacecnhaiwcrpyjvzl4uv4q3jzoif26okl3m66q3cijp3dfwlcxwztwo"),
Actors: map[string]cid.Cid{
"account": MustParseCid("bafk2bzacealnlr7st6lkwoh6wxpf2hnrlex5sknaopgmkr2tuhg7vmbfy45so"),
"cron": MustParseCid("bafk2bzacebpewdvvgt6tk2o2u4rcovdgym67tadiis5usemlbejg7k3kt567o"),
"datacap": MustParseCid("bafk2bzacebslykoyrb2hm7aacjngqgd5n2wmeii2goadrs5zaya3pvdf6pdnq"),
"eam": MustParseCid("bafk2bzaceaelwt4yfsfvsu3pa3miwalsvy3cfkcjvmt4sqoeopsppnrmj2mf2"),
"ethaccount": MustParseCid("bafk2bzaceclkmc4yidxc6lgcjpfypbde2eddnevcveo4j5kmh4ek6inqysz2k"),
"evm": MustParseCid("bafk2bzacediwh6etwzwmb5pivtclpdplewdjzphouwqpppce6opisjv2fjqfe"),
"init": MustParseCid("bafk2bzaceckwf3w6n2nw6eh77ktmsxqgsvshonvgnyk5q5syyngtetxvasfxg"),
"multisig": MustParseCid("bafk2bzaceafajceqwg5ybiz7xw6rxammuirkgtuv625gzaehsqfprm4bazjmk"),
"paymentchannel": MustParseCid("bafk2bzaceb4e6cnsnviegmqvsmoxzncruvhra54piq7bwiqfqevle6oob2gvo"),
"placeholder": MustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"),
"reward": MustParseCid("bafk2bzacebwjw2vxkobs7r2kwjdqqb42h2kucyuk6flbnyzw4odg5s4mogamo"),
"storagemarket": MustParseCid("bafk2bzaceazu2j2zu4p24tr22btnqzkhzjvyjltlvsagaj6w3syevikeb5d7m"),
"storageminer": MustParseCid("bafk2bzacec24okjqrp7c7rj3hbrs5ez5apvwah2ruka6haesgfngf37mhk6us"),
"storagepower": MustParseCid("bafk2bzaceaxgloxuzg35vu7l7tohdgaq2frsfp4ejmuo7tkoxjp5zqrze6sf4"),
"system": MustParseCid("bafk2bzaced7npe5mt5nh72jxr2igi2sofoa7gedt4w6kueeke7i3xxugqpjfm"),
"verifiedregistry": MustParseCid("bafk2bzacedej3dnr62g2je2abmyjg3xqv4otvh6e26du5fcrhvw7zgcaaez3a"),
},
}, {
Network: "mainnet",
Version: 12,
BundleGitTag: "v11.0.0",
ManifestCid: MustParseCid("bafy2bzacecnhaiwcrpyjvzl4uv4q3jzoif26okl3m66q3cijp3dfwlcxwztwo"),
Actors: map[string]cid.Cid{
@ -521,6 +636,29 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet
}, {
Network: "testing",
Version: 11,
ManifestCid: MustParseCid("bafy2bzacea2vxre32tg3xhpejrktiuzx4d3pcoe7yyazgscfibmegmchr6n42"),
Actors: map[string]cid.Cid{
"account": MustParseCid("bafk2bzaceccerssb3tgel6ukdghlwvs7dxsolj4fpkgn7dh7owzwapqb6ejpw"),
"cron": MustParseCid("bafk2bzacebtfl6fczxnitrqqjhyefskf3asyn3gzuvqcddieoqfsaddk5fd4q"),
"datacap": MustParseCid("bafk2bzacediikc55y6uzmnhucf4mik6rqpjulwvgp5gdibogxjhgbvusmzff2"),
"eam": MustParseCid("bafk2bzaceazqi5ezossp6kvqogaaba6hxlfarqgniktmb7iy5qonha3eflz6m"),
"ethaccount": MustParseCid("bafk2bzaceb77ospgfqqmf67v23wkyeg7lr2mu53ybaacu3bslx7s7nhttdueo"),
"evm": MustParseCid("bafk2bzacedvgt7mv22hux4vrnklylq7qmw43kfrqwam6wdsfzkdnaewr33qbu"),
"init": MustParseCid("bafk2bzacealzb3nk2oypway5ubz3hs5py5ok5tuw545454vg4d3mwbslef4js"),
"multisig": MustParseCid("bafk2bzacec45ppn4hrwizmopp2v2atkxw35tb6yem6uqhqilrv7aiaknnnxmu"),
"paymentchannel": MustParseCid("bafk2bzaceajbr3t6cngzh3katqteflbcrtwtdgbthnlfemon5tg6rytf2uonw"),
"placeholder": MustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"),
"reward": MustParseCid("bafk2bzacea7ycf53kbq4robcuh3ziy7qwwhaqamc5krn3lugypgpxhlewdaiq"),
"storagemarket": MustParseCid("bafk2bzacedskmbcpaeb6bezs32szh52jrukvihobluadauayroo5gzrt32tkm"),
"storageminer": MustParseCid("bafk2bzaced3yg5lctmswnbkxyd6cleg3llyux7fu2vbddyd2ho36fpym423mq"),
"storagepower": MustParseCid("bafk2bzacebvpdf372fzxgixztbz2r7ayxyvx7jmdxwlfuqt2cq7tnqgie3klw"),
"system": MustParseCid("bafk2bzaceaatvscbnkv36ixhtt2zel4er5oskxevgumh5gegqkv7uzah36f24"),
"verifiedregistry": MustParseCid("bafk2bzacebp2r56wxadvfzpfbmqwfi3dlnwpmoc5u4tau2hfftbkuafkhye64"),
},
}, {
Network: "testing",
Version: 12,
BundleGitTag: "v11.0.0",
ManifestCid: MustParseCid("bafy2bzacea2vxre32tg3xhpejrktiuzx4d3pcoe7yyazgscfibmegmchr6n42"),
Actors: map[string]cid.Cid{
@ -604,6 +742,29 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet
}, {
Network: "testing-fake-proofs",
Version: 11,
ManifestCid: MustParseCid("bafy2bzacecojemqglhzzhjnhgtrcbsgkyv67ziytvtbhwlr4ym4oxqofv7zui"),
Actors: map[string]cid.Cid{
"account": MustParseCid("bafk2bzaceccerssb3tgel6ukdghlwvs7dxsolj4fpkgn7dh7owzwapqb6ejpw"),
"cron": MustParseCid("bafk2bzacebtfl6fczxnitrqqjhyefskf3asyn3gzuvqcddieoqfsaddk5fd4q"),
"datacap": MustParseCid("bafk2bzacediikc55y6uzmnhucf4mik6rqpjulwvgp5gdibogxjhgbvusmzff2"),
"eam": MustParseCid("bafk2bzaceazqi5ezossp6kvqogaaba6hxlfarqgniktmb7iy5qonha3eflz6m"),
"ethaccount": MustParseCid("bafk2bzaceb77ospgfqqmf67v23wkyeg7lr2mu53ybaacu3bslx7s7nhttdueo"),
"evm": MustParseCid("bafk2bzacedvgt7mv22hux4vrnklylq7qmw43kfrqwam6wdsfzkdnaewr33qbu"),
"init": MustParseCid("bafk2bzacealzb3nk2oypway5ubz3hs5py5ok5tuw545454vg4d3mwbslef4js"),
"multisig": MustParseCid("bafk2bzacec45ppn4hrwizmopp2v2atkxw35tb6yem6uqhqilrv7aiaknnnxmu"),
"paymentchannel": MustParseCid("bafk2bzaceajbr3t6cngzh3katqteflbcrtwtdgbthnlfemon5tg6rytf2uonw"),
"placeholder": MustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"),
"reward": MustParseCid("bafk2bzacea7ycf53kbq4robcuh3ziy7qwwhaqamc5krn3lugypgpxhlewdaiq"),
"storagemarket": MustParseCid("bafk2bzacedskmbcpaeb6bezs32szh52jrukvihobluadauayroo5gzrt32tkm"),
"storageminer": MustParseCid("bafk2bzacebqeztpa5exztccqjwqhan5droiy7ga6zekm6f2gzxoe655vneczm"),
"storagepower": MustParseCid("bafk2bzaceb2tlyuwxncdxsh3hc4fwcjnpxaijkiv54ustwdjbrqabxdsc27km"),
"system": MustParseCid("bafk2bzaceaatvscbnkv36ixhtt2zel4er5oskxevgumh5gegqkv7uzah36f24"),
"verifiedregistry": MustParseCid("bafk2bzacebp2r56wxadvfzpfbmqwfi3dlnwpmoc5u4tau2hfftbkuafkhye64"),
},
}, {
Network: "testing-fake-proofs",
Version: 12,
BundleGitTag: "v11.0.0",
ManifestCid: MustParseCid("bafy2bzacecojemqglhzzhjnhgtrcbsgkyv67ziytvtbhwlr4ym4oxqofv7zui"),
Actors: map[string]cid.Cid{

View File

@ -61,9 +61,11 @@ var UpgradeSharkHeight = abi.ChainEpoch(-20)
var UpgradeHyggeHeight = abi.ChainEpoch(-21)
var UpgradeLightningHeight = abi.ChainEpoch(30)
var UpgradeLightningHeight = abi.ChainEpoch(-22)
var UpgradeThunderHeight = abi.ChainEpoch(1000)
var UpgradeThunderHeight = abi.ChainEpoch(-23)
var UpgradeWatermelonHeight = abi.ChainEpoch(200)
var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,
@ -120,6 +122,7 @@ func init() {
UpgradeHyggeHeight = getUpgradeHeight("LOTUS_HYGGE_HEIGHT", UpgradeHyggeHeight)
UpgradeLightningHeight = getUpgradeHeight("LOTUS_LIGHTNING_HEIGHT", UpgradeLightningHeight)
UpgradeThunderHeight = getUpgradeHeight("LOTUS_THUNDER_HEIGHT", UpgradeThunderHeight)
UpgradeWatermelonHeight = getUpgradeHeight("LOTUS_Watermelon_HEIGHT", UpgradeWatermelonHeight)
BuildType |= Build2k

View File

@ -57,6 +57,9 @@ const UpgradeLightningHeight = 50
const UpgradeThunderHeight = UpgradeLightningHeight + 360
// ??????????
const UpgradeWatermelonHeight = 999999999999999
var SupportedProofTypes = []abi.RegisteredSealProof{
abi.RegisteredSealProof_StackedDrg512MiBV1,
abi.RegisteredSealProof_StackedDrg32GiBV1,

View File

@ -79,6 +79,9 @@ const UpgradeLightningHeight = 489094
// 2023-04-21T16:00:00Z
const UpgradeThunderHeight = UpgradeLightningHeight + 3120
// ??????????
const UpgradeWatermelonHeight = 999999999999999
var SupportedProofTypes = []abi.RegisteredSealProof{
abi.RegisteredSealProof_StackedDrg32GiBV1,
abi.RegisteredSealProof_StackedDrg64GiBV1,

View File

@ -52,8 +52,9 @@ var UpgradeSkyrHeight = abi.ChainEpoch(-19)
var UpgradeSharkHeight = abi.ChainEpoch(-20)
var UpgradeHyggeHeight = abi.ChainEpoch(-21)
var UpgradeLightningHeight = abi.ChainEpoch(-22)
var UpgradeThunderHeight = abi.ChainEpoch(-23)
const UpgradeThunderHeight = 50
const UpgradeWatermelonHeight = 50
var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,

View File

@ -90,10 +90,13 @@ const UpgradeSharkHeight = 2383680
const UpgradeHyggeHeight = 2683348
// 2023-04-27T13:00:00Z
var UpgradeLightningHeight = abi.ChainEpoch(2809800)
const UpgradeLightningHeight = 2809800
// 2023-05-18T13:00:00Z
var UpgradeThunderHeight = UpgradeLightningHeight + 2880*21
const UpgradeThunderHeight = UpgradeLightningHeight + 2880*21
// ???????
var UpgradeWatermelonHeight = abi.ChainEpoch(9999999999)
var SupportedProofTypes = []abi.RegisteredSealProof{
abi.RegisteredSealProof_StackedDrg32GiBV1,
@ -108,12 +111,8 @@ func init() {
SetAddressNetwork(address.Mainnet)
}
if os.Getenv("LOTUS_DISABLE_LIGHTNING") == "1" {
UpgradeLightningHeight = math.MaxInt64
}
if os.Getenv("LOTUS_DISABLE_THUNDER") == "1" {
UpgradeThunderHeight = math.MaxInt64
if os.Getenv("LOTUS_DISABLE_Watermelon") == "1" {
UpgradeWatermelonHeight = math.MaxInt64
}
// NOTE: DO NOT change this unless you REALLY know what you're doing. This is not consensus critical, however,

View File

@ -30,7 +30,7 @@ const AllowableClockDriftSecs = uint64(1)
/* inline-gen template
const TestNetworkVersion = network.Version{{.latestNetworkVersion}}
/* inline-gen start */
const TestNetworkVersion = network.Version20
const TestNetworkVersion = network.Version21
/* inline-gen end */

View File

@ -109,6 +109,7 @@ var (
UpgradeHyggeHeight abi.ChainEpoch = -20
UpgradeLightningHeight abi.ChainEpoch = -21
UpgradeThunderHeight abi.ChainEpoch = -22
UpgradeWatermelonHeight abi.ChainEpoch = -23
DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,

View File

@ -6,7 +6,7 @@ import (
"github.com/filecoin-project/go-address"
actorstypes "github.com/filecoin-project/go-state-types/actors"
builtin11 "github.com/filecoin-project/go-state-types/builtin"
builtin12 "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 = builtin11.MethodsAccount
var Methods = builtin12.MethodsAccount
func Load(store adt.Store, act *types.Actor) (State, error) {
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
@ -44,6 +44,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
case actorstypes.Version11:
return load11(store, act.Head)
case actorstypes.Version12:
return load12(store, act.Head)
}
}
@ -111,6 +114,9 @@ func MakeState(store adt.Store, av actorstypes.Version, addr address.Address) (S
case actorstypes.Version11:
return make11(store, addr)
case actorstypes.Version12:
return make12(store, addr)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
@ -139,5 +145,6 @@ func AllCodes() []cid.Cid {
(&state9{}).Code(),
(&state10{}).Code(),
(&state11{}).Code(),
(&state12{}).Code(),
}
}

62
chain/actors/builtin/account/v12.go generated Normal file
View File

@ -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"
account12 "github.com/filecoin-project/go-state-types/builtin/v12/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 = (*state12)(nil)
func load12(store adt.Store, root cid.Cid) (State, error) {
out := state12{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make12(store adt.Store, addr address.Address) (State, error) {
out := state12{store: store}
out.State = account12.State{Address: addr}
return &out, nil
}
type state12 struct {
account12.State
store adt.Store
}
func (s *state12) PubkeyAddress() (address.Address, error) {
return s.Address, nil
}
func (s *state12) GetState() interface{} {
return &s.State
}
func (s *state12) ActorKey() string {
return manifest.AccountKey
}
func (s *state12) ActorVersion() actorstypes.Version {
return actorstypes.Version12
}
func (s *state12) 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
}

View File

@ -5,7 +5,7 @@ import (
"golang.org/x/xerrors"
actorstypes "github.com/filecoin-project/go-state-types/actors"
builtin11 "github.com/filecoin-project/go-state-types/builtin"
builtin12 "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"
@ -40,6 +40,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
case actorstypes.Version11:
return load11(store, act.Head)
case actorstypes.Version12:
return load12(store, act.Head)
}
}
@ -107,13 +110,16 @@ func MakeState(store adt.Store, av actorstypes.Version) (State, error) {
case actorstypes.Version11:
return make11(store)
case actorstypes.Version12:
return make12(store)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
var (
Address = builtin11.CronActorAddr
Methods = builtin11.MethodsCron
Address = builtin12.CronActorAddr
Methods = builtin12.MethodsCron
)
type State interface {
@ -137,5 +143,6 @@ func AllCodes() []cid.Cid {
(&state9{}).Code(),
(&state10{}).Code(),
(&state11{}).Code(),
(&state12{}).Code(),
}
}

57
chain/actors/builtin/cron/v12.go generated Normal file
View File

@ -0,0 +1,57 @@
package cron
import (
"fmt"
"github.com/ipfs/go-cid"
actorstypes "github.com/filecoin-project/go-state-types/actors"
cron12 "github.com/filecoin-project/go-state-types/builtin/v12/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 = (*state12)(nil)
func load12(store adt.Store, root cid.Cid) (State, error) {
out := state12{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make12(store adt.Store) (State, error) {
out := state12{store: store}
out.State = *cron12.ConstructState(cron12.BuiltInEntries())
return &out, nil
}
type state12 struct {
cron12.State
store adt.Store
}
func (s *state12) GetState() interface{} {
return &s.State
}
func (s *state12) ActorKey() string {
return manifest.CronKey
}
func (s *state12) ActorVersion() actorstypes.Version {
return actorstypes.Version12
}
func (s *state12) 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
}

View File

@ -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"
builtin11 "github.com/filecoin-project/go-state-types/builtin"
builtin12 "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 = builtin11.DatacapActorAddr
Methods = builtin11.MethodsDatacap
Address = builtin12.DatacapActorAddr
Methods = builtin12.MethodsDatacap
)
func Load(store adt.Store, act *types.Actor) (State, error) {
@ -38,6 +38,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
case actorstypes.Version11:
return load11(store, act.Head)
case actorstypes.Version12:
return load12(store, act.Head)
}
}
@ -56,6 +59,9 @@ func MakeState(store adt.Store, av actorstypes.Version, governor address.Address
case actorstypes.Version11:
return make11(store, governor, bitwidth)
case actorstypes.Version12:
return make12(store, governor, bitwidth)
default:
return nil, xerrors.Errorf("datacap actor only valid for actors v9 and above, got %d", av)
}
@ -79,5 +85,6 @@ func AllCodes() []cid.Cid {
(&state9{}).Code(),
(&state10{}).Code(),
(&state11{}).Code(),
(&state12{}).Code(),
}
}

82
chain/actors/builtin/datacap/v12.go generated Normal file
View File

@ -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"
datacap12 "github.com/filecoin-project/go-state-types/builtin/v12/datacap"
adt12 "github.com/filecoin-project/go-state-types/builtin/v12/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 = (*state12)(nil)
func load12(store adt.Store, root cid.Cid) (State, error) {
out := state12{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make12(store adt.Store, governor address.Address, bitwidth uint64) (State, error) {
out := state12{store: store}
s, err := datacap12.ConstructState(store, governor, bitwidth)
if err != nil {
return nil, err
}
out.State = *s
return &out, nil
}
type state12 struct {
datacap12.State
store adt.Store
}
func (s *state12) Governor() (address.Address, error) {
return s.State.Governor, nil
}
func (s *state12) GetState() interface{} {
return &s.State
}
func (s *state12) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error {
return forEachClient(s.store, actors.Version12, s.verifiedClients, cb)
}
func (s *state12) verifiedClients() (adt.Map, error) {
return adt12.AsMap(s.store, s.Token.Balances, int(s.Token.HamtBitWidth))
}
func (s *state12) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) {
return getDataCap(s.store, actors.Version12, s.verifiedClients, addr)
}
func (s *state12) ActorKey() string {
return manifest.DatacapKey
}
func (s *state12) ActorVersion() actorstypes.Version {
return actorstypes.Version12
}
func (s *state12) 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
}

View File

@ -5,7 +5,7 @@ import (
"golang.org/x/xerrors"
actorstypes "github.com/filecoin-project/go-state-types/actors"
builtin11 "github.com/filecoin-project/go-state-types/builtin"
builtin12 "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 = builtin11.MethodsEVM
var Methods = builtin12.MethodsEVM
func Load(store adt.Store, act *types.Actor) (State, error) {
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
@ -30,6 +30,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
case actorstypes.Version11:
return load11(store, act.Head)
case actorstypes.Version12:
return load12(store, act.Head)
}
}
@ -45,6 +48,9 @@ func MakeState(store adt.Store, av actorstypes.Version, bytecode cid.Cid) (State
case actorstypes.Version11:
return make11(store, bytecode)
case actorstypes.Version12:
return make12(store, bytecode)
default:
return nil, xerrors.Errorf("evm actor only valid for actors v10 and above, got %d", av)
}

72
chain/actors/builtin/evm/v12.go generated Normal file
View File

@ -0,0 +1,72 @@
package evm
import (
"github.com/ipfs/go-cid"
"github.com/filecoin-project/go-state-types/abi"
evm12 "github.com/filecoin-project/go-state-types/builtin/v12/evm"
"github.com/filecoin-project/lotus/chain/actors/adt"
)
var _ State = (*state12)(nil)
func load12(store adt.Store, root cid.Cid) (State, error) {
out := state12{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make12(store adt.Store, bytecode cid.Cid) (State, error) {
out := state12{store: store}
s, err := evm12.ConstructState(store, bytecode)
if err != nil {
return nil, err
}
out.State = *s
return &out, nil
}
type state12 struct {
evm12.State
store adt.Store
}
func (s *state12) Nonce() (uint64, error) {
return s.State.Nonce, nil
}
func (s *state12) IsAlive() (bool, error) {
return s.State.Tombstone == nil, nil
}
func (s *state12) GetState() interface{} {
return &s.State
}
func (s *state12) GetBytecodeCID() (cid.Cid, error) {
return s.State.Bytecode, nil
}
func (s *state12) GetBytecodeHash() ([32]byte, error) {
return s.State.BytecodeHash, nil
}
func (s *state12) 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
}

View File

@ -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"
builtin11 "github.com/filecoin-project/go-state-types/builtin"
builtin12 "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 = builtin11.InitActorAddr
Methods = builtin11.MethodsInit
Address = builtin12.InitActorAddr
Methods = builtin12.MethodsInit
)
func Load(store adt.Store, act *types.Actor) (State, error) {
@ -49,6 +49,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
case actorstypes.Version11:
return load11(store, act.Head)
case actorstypes.Version12:
return load12(store, act.Head)
}
}
@ -116,6 +119,9 @@ func MakeState(store adt.Store, av actorstypes.Version, networkName string) (Sta
case actorstypes.Version11:
return make11(store, networkName)
case actorstypes.Version12:
return make12(store, networkName)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
@ -167,5 +173,6 @@ func AllCodes() []cid.Cid {
(&state9{}).Code(),
(&state10{}).Code(),
(&state11{}).Code(),
(&state12{}).Code(),
}
}

147
chain/actors/builtin/init/v12.go generated Normal file
View File

@ -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"
builtin12 "github.com/filecoin-project/go-state-types/builtin"
init12 "github.com/filecoin-project/go-state-types/builtin/v12/init"
adt12 "github.com/filecoin-project/go-state-types/builtin/v12/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 = (*state12)(nil)
func load12(store adt.Store, root cid.Cid) (State, error) {
out := state12{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make12(store adt.Store, networkName string) (State, error) {
out := state12{store: store}
s, err := init12.ConstructState(store, networkName)
if err != nil {
return nil, err
}
out.State = *s
return &out, nil
}
type state12 struct {
init12.State
store adt.Store
}
func (s *state12) ResolveAddress(address address.Address) (address.Address, bool, error) {
return s.State.ResolveAddress(s.store, address)
}
func (s *state12) MapAddressToNewID(address address.Address) (address.Address, error) {
return s.State.MapAddressToNewID(s.store, address)
}
func (s *state12) ForEachActor(cb func(id abi.ActorID, address address.Address) error) error {
addrs, err := adt12.AsMap(s.store, s.State.AddressMap, builtin12.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 *state12) NetworkName() (dtypes.NetworkName, error) {
return dtypes.NetworkName(s.State.NetworkName), nil
}
func (s *state12) SetNetworkName(name string) error {
s.State.NetworkName = name
return nil
}
func (s *state12) SetNextID(id abi.ActorID) error {
s.State.NextID = id
return nil
}
func (s *state12) Remove(addrs ...address.Address) (err error) {
m, err := adt12.AsMap(s.store, s.State.AddressMap, builtin12.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 *state12) SetAddressMap(mcid cid.Cid) error {
s.State.AddressMap = mcid
return nil
}
func (s *state12) GetState() interface{} {
return &s.State
}
func (s *state12) AddressMap() (adt.Map, error) {
return adt12.AsMap(s.store, s.State.AddressMap, builtin12.DefaultHamtBitwidth)
}
func (s *state12) AddressMapBitWidth() int {
return builtin12.DefaultHamtBitwidth
}
func (s *state12) AddressMapHashFunction() func(input []byte) []byte {
return func(input []byte) []byte {
res := sha256.Sum256(input)
return res[:]
}
}
func (s *state12) ActorKey() string {
return manifest.InitKey
}
func (s *state12) ActorVersion() actorstypes.Version {
return actorstypes.Version12
}
func (s *state12) 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
}

View File

@ -55,6 +55,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
case actorstypes.Version11:
return load11(store, act.Head)
case actorstypes.Version12:
return load12(store, act.Head)
}
}
@ -122,6 +125,9 @@ func MakeState(store adt.Store, av actorstypes.Version) (State, error) {
case actorstypes.Version11:
return make11(store)
case actorstypes.Version12:
return make12(store)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
@ -217,6 +223,9 @@ func DecodePublishStorageDealsReturn(b []byte, nv network.Version) (PublishStora
case actorstypes.Version11:
return decodePublishStorageDealsReturn11(b)
case actorstypes.Version12:
return decodePublishStorageDealsReturn12(b)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
@ -303,5 +312,6 @@ func AllCodes() []cid.Cid {
(&state9{}).Code(),
(&state10{}).Code(),
(&state11{}).Code(),
(&state12{}).Code(),
}
}

377
chain/actors/builtin/market/v12.go generated Normal file
View File

@ -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"
market12 "github.com/filecoin-project/go-state-types/builtin/v12/market"
adt12 "github.com/filecoin-project/go-state-types/builtin/v12/util/adt"
markettypes "github.com/filecoin-project/go-state-types/builtin/v9/market"
verifregtypes "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"
"github.com/filecoin-project/lotus/chain/types"
)
var _ State = (*state12)(nil)
func load12(store adt.Store, root cid.Cid) (State, error) {
out := state12{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make12(store adt.Store) (State, error) {
out := state12{store: store}
s, err := market12.ConstructState(store)
if err != nil {
return nil, err
}
out.State = *s
return &out, nil
}
type state12 struct {
market12.State
store adt.Store
}
func (s *state12) TotalLocked() (abi.TokenAmount, error) {
fml := types.BigAdd(s.TotalClientLockedCollateral, s.TotalProviderLockedCollateral)
fml = types.BigAdd(fml, s.TotalClientStorageFee)
return fml, nil
}
func (s *state12) BalancesChanged(otherState State) (bool, error) {
otherState12, ok := otherState.(*state12)
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(otherState12.State.EscrowTable) || !s.State.LockedTable.Equals(otherState12.State.LockedTable), nil
}
func (s *state12) StatesChanged(otherState State) (bool, error) {
otherState12, ok := otherState.(*state12)
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(otherState12.State.States), nil
}
func (s *state12) States() (DealStates, error) {
stateArray, err := adt12.AsArray(s.store, s.State.States, market12.StatesAmtBitwidth)
if err != nil {
return nil, err
}
return &dealStates12{stateArray}, nil
}
func (s *state12) ProposalsChanged(otherState State) (bool, error) {
otherState12, ok := otherState.(*state12)
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(otherState12.State.Proposals), nil
}
func (s *state12) Proposals() (DealProposals, error) {
proposalArray, err := adt12.AsArray(s.store, s.State.Proposals, market12.ProposalsAmtBitwidth)
if err != nil {
return nil, err
}
return &dealProposals12{proposalArray}, nil
}
func (s *state12) EscrowTable() (BalanceTable, error) {
bt, err := adt12.AsBalanceTable(s.store, s.State.EscrowTable)
if err != nil {
return nil, err
}
return &balanceTable12{bt}, nil
}
func (s *state12) LockedTable() (BalanceTable, error) {
bt, err := adt12.AsBalanceTable(s.store, s.State.LockedTable)
if err != nil {
return nil, err
}
return &balanceTable12{bt}, nil
}
func (s *state12) VerifyDealsForActivation(
minerAddr address.Address, deals []abi.DealID, currEpoch, sectorExpiry abi.ChainEpoch,
) (weight, verifiedWeight abi.DealWeight, err error) {
w, vw, _, err := market12.ValidateDealsForActivation(&s.State, s.store, deals, minerAddr, sectorExpiry, currEpoch)
return w, vw, err
}
func (s *state12) NextID() (abi.DealID, error) {
return s.State.NextID, nil
}
type balanceTable12 struct {
*adt12.BalanceTable
}
func (bt *balanceTable12) ForEach(cb func(address.Address, abi.TokenAmount) error) error {
asMap := (*adt12.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 dealStates12 struct {
adt.Array
}
func (s *dealStates12) Get(dealID abi.DealID) (*DealState, bool, error) {
var deal12 market12.DealState
found, err := s.Array.Get(uint64(dealID), &deal12)
if err != nil {
return nil, false, err
}
if !found {
return nil, false, nil
}
deal := fromV12DealState(deal12)
return &deal, true, nil
}
func (s *dealStates12) ForEach(cb func(dealID abi.DealID, ds DealState) error) error {
var ds12 market12.DealState
return s.Array.ForEach(&ds12, func(idx int64) error {
return cb(abi.DealID(idx), fromV12DealState(ds12))
})
}
func (s *dealStates12) decode(val *cbg.Deferred) (*DealState, error) {
var ds12 market12.DealState
if err := ds12.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return nil, err
}
ds := fromV12DealState(ds12)
return &ds, nil
}
func (s *dealStates12) array() adt.Array {
return s.Array
}
func fromV12DealState(v12 market12.DealState) DealState {
ret := DealState{
SectorStartEpoch: v12.SectorStartEpoch,
LastUpdatedEpoch: v12.LastUpdatedEpoch,
SlashEpoch: v12.SlashEpoch,
VerifiedClaim: 0,
}
ret.VerifiedClaim = verifregtypes.AllocationId(v12.VerifiedClaim)
return ret
}
type dealProposals12 struct {
adt.Array
}
func (s *dealProposals12) Get(dealID abi.DealID) (*DealProposal, bool, error) {
var proposal12 market12.DealProposal
found, err := s.Array.Get(uint64(dealID), &proposal12)
if err != nil {
return nil, false, err
}
if !found {
return nil, false, nil
}
proposal, err := fromV12DealProposal(proposal12)
if err != nil {
return nil, true, xerrors.Errorf("decoding proposal: %w", err)
}
return &proposal, true, nil
}
func (s *dealProposals12) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error {
var dp12 market12.DealProposal
return s.Array.ForEach(&dp12, func(idx int64) error {
dp, err := fromV12DealProposal(dp12)
if err != nil {
return xerrors.Errorf("decoding proposal: %w", err)
}
return cb(abi.DealID(idx), dp)
})
}
func (s *dealProposals12) decode(val *cbg.Deferred) (*DealProposal, error) {
var dp12 market12.DealProposal
if err := dp12.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return nil, err
}
dp, err := fromV12DealProposal(dp12)
if err != nil {
return nil, err
}
return &dp, nil
}
func (s *dealProposals12) array() adt.Array {
return s.Array
}
func fromV12DealProposal(v12 market12.DealProposal) (DealProposal, error) {
label, err := fromV12Label(v12.Label)
if err != nil {
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
}
return DealProposal{
PieceCID: v12.PieceCID,
PieceSize: v12.PieceSize,
VerifiedDeal: v12.VerifiedDeal,
Client: v12.Client,
Provider: v12.Provider,
Label: label,
StartEpoch: v12.StartEpoch,
EndEpoch: v12.EndEpoch,
StoragePricePerEpoch: v12.StoragePricePerEpoch,
ProviderCollateral: v12.ProviderCollateral,
ClientCollateral: v12.ClientCollateral,
}, nil
}
func fromV12Label(v12 market12.DealLabel) (DealLabel, error) {
if v12.IsString() {
str, err := v12.ToString()
if err != nil {
return markettypes.EmptyDealLabel, xerrors.Errorf("failed to convert string label to string: %w", err)
}
return markettypes.NewLabelFromString(str)
}
bs, err := v12.ToBytes()
if err != nil {
return markettypes.EmptyDealLabel, xerrors.Errorf("failed to convert bytes label to bytes: %w", err)
}
return markettypes.NewLabelFromBytes(bs)
}
func (s *state12) GetState() interface{} {
return &s.State
}
var _ PublishStorageDealsReturn = (*publishStorageDealsReturn12)(nil)
func decodePublishStorageDealsReturn12(b []byte) (PublishStorageDealsReturn, error) {
var retval market12.PublishStorageDealsReturn
if err := retval.UnmarshalCBOR(bytes.NewReader(b)); err != nil {
return nil, xerrors.Errorf("failed to unmarshal PublishStorageDealsReturn: %w", err)
}
return &publishStorageDealsReturn12{retval}, nil
}
type publishStorageDealsReturn12 struct {
market12.PublishStorageDealsReturn
}
func (r *publishStorageDealsReturn12) 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 *publishStorageDealsReturn12) DealIDs() ([]abi.DealID, error) {
return r.IDs, nil
}
func (s *state12) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes.AllocationId, error) {
allocations, err := adt12.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 *state12) ActorKey() string {
return manifest.MarketKey
}
func (s *state12) ActorVersion() actorstypes.Version {
return actorstypes.Version12
}
func (s *state12) 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
}

View File

@ -48,6 +48,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
case actorstypes.Version11:
return load11(store, act.Head)
case actorstypes.Version12:
return load12(store, act.Head)
}
}
@ -115,6 +118,9 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
case actors.Version11:
return make11(store)
case actors.Version12:
return make12(store)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
@ -321,5 +327,6 @@ func AllCodes() []cid.Cid {
(&state9{}).Code(),
(&state10{}).Code(),
(&state11{}).Code(),
(&state12{}).Code(),
}
}

591
chain/actors/builtin/miner/v12.go generated Normal file
View File

@ -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"
builtin12 "github.com/filecoin-project/go-state-types/builtin"
miner12 "github.com/filecoin-project/go-state-types/builtin/v12/miner"
adt12 "github.com/filecoin-project/go-state-types/builtin/v12/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 = (*state12)(nil)
func load12(store adt.Store, root cid.Cid) (State, error) {
out := state12{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make12(store adt.Store) (State, error) {
out := state12{store: store}
out.State = miner12.State{}
return &out, nil
}
type state12 struct {
miner12.State
store adt.Store
}
type deadline12 struct {
miner12.Deadline
store adt.Store
}
type partition12 struct {
miner12.Partition
store adt.Store
}
func (s *state12) 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 doesnt have enough funds to cover their locked pledge
available, err = s.GetAvailableBalance(bal)
return available, err
}
func (s *state12) VestedFunds(epoch abi.ChainEpoch) (abi.TokenAmount, error) {
return s.CheckVestedFunds(s.store, epoch)
}
func (s *state12) LockedFunds() (LockedFunds, error) {
return LockedFunds{
VestingFunds: s.State.LockedFunds,
InitialPledgeRequirement: s.State.InitialPledge,
PreCommitDeposits: s.State.PreCommitDeposits,
}, nil
}
func (s *state12) FeeDebt() (abi.TokenAmount, error) {
return s.State.FeeDebt, nil
}
func (s *state12) InitialPledge() (abi.TokenAmount, error) {
return s.State.InitialPledge, nil
}
func (s *state12) PreCommitDeposits() (abi.TokenAmount, error) {
return s.State.PreCommitDeposits, nil
}
// Returns nil, nil if sector is not found
func (s *state12) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) {
info, ok, err := s.State.GetSector(s.store, num)
if !ok || err != nil {
return nil, err
}
ret := fromV12SectorOnChainInfo(*info)
return &ret, nil
}
func (s *state12) 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 *state12) 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 *miner12.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 *state12) 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 *miner12.Deadline) error {
partitions, err := dl.PartitionsArray(s.store)
if err != nil {
return err
}
quant := s.State.QuantSpecForDeadline(dlIdx)
var part miner12.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 := miner12.LoadExpirationQueue(s.store, part.ExpirationsEpochs, quant, miner12.PartitionExpirationAmtBitwidth)
if err != nil {
return err
}
var exp miner12.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 *state12) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) {
info, ok, err := s.State.GetPrecommittedSector(s.store, num)
if !ok || err != nil {
return nil, err
}
ret := fromV12SectorPreCommitOnChainInfo(*info)
return &ret, nil
}
func (s *state12) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error {
precommitted, err := adt12.AsMap(s.store, s.State.PreCommittedSectors, builtin12.DefaultHamtBitwidth)
if err != nil {
return err
}
var info miner12.SectorPreCommitOnChainInfo
if err := precommitted.ForEach(&info, func(_ string) error {
return cb(fromV12SectorPreCommitOnChainInfo(info))
}); err != nil {
return err
}
return nil
}
func (s *state12) LoadSectors(snos *bitfield.BitField) ([]*SectorOnChainInfo, error) {
sectors, err := miner12.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 info12 miner12.SectorOnChainInfo
if err := sectors.ForEach(&info12, func(_ int64) error {
info := fromV12SectorOnChainInfo(info12)
infos = append(infos, &info)
return nil
}); err != nil {
return nil, err
}
return infos, nil
}
// Otherwise, load selected.
infos12, err := sectors.Load(*snos)
if err != nil {
return nil, err
}
infos := make([]*SectorOnChainInfo, len(infos12))
for i, info12 := range infos12 {
info := fromV12SectorOnChainInfo(*info12)
infos[i] = &info
}
return infos, nil
}
func (s *state12) loadAllocatedSectorNumbers() (bitfield.BitField, error) {
var allocatedSectors bitfield.BitField
err := s.store.Get(s.store.Context(), s.State.AllocatedSectors, &allocatedSectors)
return allocatedSectors, err
}
func (s *state12) IsAllocated(num abi.SectorNumber) (bool, error) {
allocatedSectors, err := s.loadAllocatedSectorNumbers()
if err != nil {
return false, err
}
return allocatedSectors.IsSet(uint64(num))
}
func (s *state12) GetProvingPeriodStart() (abi.ChainEpoch, error) {
return s.State.ProvingPeriodStart, nil
}
func (s *state12) 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 *state12) 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 *state12) 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 &deadline12{*dl, s.store}, nil
}
func (s *state12) 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 *miner12.Deadline) error {
return cb(i, &deadline12{*dl, s.store})
})
}
func (s *state12) NumDeadlines() (uint64, error) {
return miner12.WPoStPeriodDeadlines, nil
}
func (s *state12) DeadlinesChanged(other State) (bool, error) {
other12, ok := other.(*state12)
if !ok {
// treat an upgrade as a change, always
return true, nil
}
return !s.State.Deadlines.Equals(other12.Deadlines), nil
}
func (s *state12) MinerInfoChanged(other State) (bool, error) {
other0, ok := other.(*state12)
if !ok {
// treat an upgrade as a change, always
return true, nil
}
return !s.State.Info.Equals(other0.State.Info), nil
}
func (s *state12) 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 *state12) DeadlineInfo(epoch abi.ChainEpoch) (*dline.Info, error) {
return s.State.RecordedDeadlineInfo(epoch), nil
}
func (s *state12) DeadlineCronActive() (bool, error) {
return s.State.DeadlineCronActive, nil
}
func (s *state12) sectors() (adt.Array, error) {
return adt12.AsArray(s.store, s.Sectors, miner12.SectorsAmtBitwidth)
}
func (s *state12) decodeSectorOnChainInfo(val *cbg.Deferred) (SectorOnChainInfo, error) {
var si miner12.SectorOnChainInfo
err := si.UnmarshalCBOR(bytes.NewReader(val.Raw))
if err != nil {
return SectorOnChainInfo{}, err
}
return fromV12SectorOnChainInfo(si), nil
}
func (s *state12) precommits() (adt.Map, error) {
return adt12.AsMap(s.store, s.PreCommittedSectors, builtin12.DefaultHamtBitwidth)
}
func (s *state12) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) {
var sp miner12.SectorPreCommitOnChainInfo
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
if err != nil {
return SectorPreCommitOnChainInfo{}, err
}
return fromV12SectorPreCommitOnChainInfo(sp), nil
}
func (s *state12) EraseAllUnproven() error {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return err
}
err = dls.ForEach(s.store, func(dindx uint64, dl *miner12.Deadline) error {
ps, err := dl.PartitionsArray(s.store)
if err != nil {
return err
}
var part miner12.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 *deadline12) LoadPartition(idx uint64) (Partition, error) {
p, err := d.Deadline.LoadPartition(d.store, idx)
if err != nil {
return nil, err
}
return &partition12{*p, d.store}, nil
}
func (d *deadline12) ForEachPartition(cb func(uint64, Partition) error) error {
ps, err := d.Deadline.PartitionsArray(d.store)
if err != nil {
return err
}
var part miner12.Partition
return ps.ForEach(&part, func(i int64) error {
return cb(uint64(i), &partition12{part, d.store})
})
}
func (d *deadline12) PartitionsChanged(other Deadline) (bool, error) {
other12, ok := other.(*deadline12)
if !ok {
// treat an upgrade as a change, always
return true, nil
}
return !d.Deadline.Partitions.Equals(other12.Deadline.Partitions), nil
}
func (d *deadline12) PartitionsPoSted() (bitfield.BitField, error) {
return d.Deadline.PartitionsPoSted, nil
}
func (d *deadline12) DisputableProofCount() (uint64, error) {
ops, err := d.OptimisticProofsSnapshotArray(d.store)
if err != nil {
return 0, err
}
return ops.Length(), nil
}
func (p *partition12) AllSectors() (bitfield.BitField, error) {
return p.Partition.Sectors, nil
}
func (p *partition12) FaultySectors() (bitfield.BitField, error) {
return p.Partition.Faults, nil
}
func (p *partition12) RecoveringSectors() (bitfield.BitField, error) {
return p.Partition.Recoveries, nil
}
func (p *partition12) UnprovenSectors() (bitfield.BitField, error) {
return p.Partition.Unproven, nil
}
func fromV12SectorOnChainInfo(v12 miner12.SectorOnChainInfo) SectorOnChainInfo {
info := SectorOnChainInfo{
SectorNumber: v12.SectorNumber,
SealProof: v12.SealProof,
SealedCID: v12.SealedCID,
DealIDs: v12.DealIDs,
Activation: v12.Activation,
Expiration: v12.Expiration,
DealWeight: v12.DealWeight,
VerifiedDealWeight: v12.VerifiedDealWeight,
InitialPledge: v12.InitialPledge,
ExpectedDayReward: v12.ExpectedDayReward,
ExpectedStoragePledge: v12.ExpectedStoragePledge,
SectorKeyCID: v12.SectorKeyCID,
}
return info
}
func fromV12SectorPreCommitOnChainInfo(v12 miner12.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo {
ret := SectorPreCommitOnChainInfo{
Info: SectorPreCommitInfo{
SealProof: v12.Info.SealProof,
SectorNumber: v12.Info.SectorNumber,
SealedCID: v12.Info.SealedCID,
SealRandEpoch: v12.Info.SealRandEpoch,
DealIDs: v12.Info.DealIDs,
Expiration: v12.Info.Expiration,
UnsealedCid: nil,
},
PreCommitDeposit: v12.PreCommitDeposit,
PreCommitEpoch: v12.PreCommitEpoch,
}
ret.Info.UnsealedCid = v12.Info.UnsealedCid
return ret
}
func (s *state12) GetState() interface{} {
return &s.State
}
func (s *state12) ActorKey() string {
return manifest.MinerKey
}
func (s *state12) ActorVersion() actorstypes.Version {
return actorstypes.Version12
}
func (s *state12) 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
}

View File

@ -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"
init11 "github.com/filecoin-project/go-state-types/builtin/v11/init"
init12 "github.com/filecoin-project/go-state-types/builtin/v12/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 := &init11.ExecParams{
execParams := &init12.ExecParams{
CodeCID: code,
ConstructorParams: enc,
}

View File

@ -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"
init11 "github.com/filecoin-project/go-state-types/builtin/v11/init"
multisig11 "github.com/filecoin-project/go-state-types/builtin/v11/multisig"
init12 "github.com/filecoin-project/go-state-types/builtin/v12/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 := &init11.ExecParams{
execParams := &init12.ExecParams{
CodeCID: code,
ConstructorParams: enc,
}

View File

@ -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"
init12 "github.com/filecoin-project/go-state-types/builtin/v12/init"
multisig12 "github.com/filecoin-project/go-state-types/builtin/v12/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 message12 struct{ message0 }
func (m message12) 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 := &multisig12.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.Version12, 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 := &init12.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
}

View File

@ -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"
init11 "github.com/filecoin-project/go-state-types/builtin/v11/init"
init12 "github.com/filecoin-project/go-state-types/builtin/v12/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 := &init11.ExecParams{
execParams := &init12.ExecParams{
CodeCID: code,
ConstructorParams: enc,
}

View File

@ -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"
init11 "github.com/filecoin-project/go-state-types/builtin/v11/init"
init12 "github.com/filecoin-project/go-state-types/builtin/v12/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 := &init11.ExecParams{
execParams := &init12.ExecParams{
CodeCID: code,
ConstructorParams: enc,
}

View File

@ -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"
msig11 "github.com/filecoin-project/go-state-types/builtin/v11/multisig"
msig12 "github.com/filecoin-project/go-state-types/builtin/v12/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"
@ -48,6 +48,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
case actorstypes.Version11:
return load11(store, act.Head)
case actorstypes.Version12:
return load12(store, act.Head)
}
}
@ -115,6 +118,9 @@ func MakeState(store adt.Store, av actorstypes.Version, signers []address.Addres
case actorstypes.Version11:
return make11(store, signers, threshold, startEpoch, unlockDuration, initialBalance)
case actorstypes.Version12:
return make12(store, signers, threshold, startEpoch, unlockDuration, initialBalance)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
@ -141,7 +147,7 @@ type State interface {
GetState() interface{}
}
type Transaction = msig11.Transaction
type Transaction = msig12.Transaction
var Methods = builtintypes.MethodsMultisig
@ -180,6 +186,9 @@ func Message(version actorstypes.Version, from address.Address) MessageBuilder {
case actorstypes.Version11:
return message11{message0{from}}
case actorstypes.Version12:
return message12{message0{from}}
default:
panic(fmt.Sprintf("unsupported actors version: %d", version))
}
@ -203,13 +212,13 @@ type MessageBuilder interface {
}
// this type is the same between v0 and v2
type ProposalHashData = msig11.ProposalHashData
type ProposeReturn = msig11.ProposeReturn
type ProposeParams = msig11.ProposeParams
type ApproveReturn = msig11.ApproveReturn
type ProposalHashData = msig12.ProposalHashData
type ProposeReturn = msig12.ProposeReturn
type ProposeParams = msig12.ProposeParams
type ApproveReturn = msig12.ApproveReturn
func txnParams(id uint64, data *ProposalHashData) ([]byte, error) {
params := msig11.TxnIDParams{ID: msig11.TxnID(id)}
params := msig12.TxnIDParams{ID: msig12.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)
@ -244,5 +253,6 @@ func AllCodes() []cid.Cid {
(&state9{}).Code(),
(&state10{}).Code(),
(&state11{}).Code(),
(&state12{}).Code(),
}
}

138
chain/actors/builtin/multisig/v12.go generated Normal file
View File

@ -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"
builtin12 "github.com/filecoin-project/go-state-types/builtin"
msig12 "github.com/filecoin-project/go-state-types/builtin/v12/multisig"
adt12 "github.com/filecoin-project/go-state-types/builtin/v12/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 = (*state12)(nil)
func load12(store adt.Store, root cid.Cid) (State, error) {
out := state12{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make12(store adt.Store, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) {
out := state12{store: store}
out.State = msig12.State{}
out.State.Signers = signers
out.State.NumApprovalsThreshold = threshold
out.State.StartEpoch = startEpoch
out.State.UnlockDuration = unlockDuration
out.State.InitialBalance = initialBalance
em, err := adt12.StoreEmptyMap(store, builtin12.DefaultHamtBitwidth)
if err != nil {
return nil, err
}
out.State.PendingTxns = em
return &out, nil
}
type state12 struct {
msig12.State
store adt.Store
}
func (s *state12) LockedBalance(currEpoch abi.ChainEpoch) (abi.TokenAmount, error) {
return s.State.AmountLocked(currEpoch - s.State.StartEpoch), nil
}
func (s *state12) StartEpoch() (abi.ChainEpoch, error) {
return s.State.StartEpoch, nil
}
func (s *state12) UnlockDuration() (abi.ChainEpoch, error) {
return s.State.UnlockDuration, nil
}
func (s *state12) InitialBalance() (abi.TokenAmount, error) {
return s.State.InitialBalance, nil
}
func (s *state12) Threshold() (uint64, error) {
return s.State.NumApprovalsThreshold, nil
}
func (s *state12) Signers() ([]address.Address, error) {
return s.State.Signers, nil
}
func (s *state12) ForEachPendingTxn(cb func(id int64, txn Transaction) error) error {
arr, err := adt12.AsMap(s.store, s.State.PendingTxns, builtin12.DefaultHamtBitwidth)
if err != nil {
return err
}
var out msig12.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 *state12) PendingTxnChanged(other State) (bool, error) {
other12, ok := other.(*state12)
if !ok {
// treat an upgrade as a change, always
return true, nil
}
return !s.State.PendingTxns.Equals(other12.PendingTxns), nil
}
func (s *state12) transactions() (adt.Map, error) {
return adt12.AsMap(s.store, s.PendingTxns, builtin12.DefaultHamtBitwidth)
}
func (s *state12) decodeTransaction(val *cbg.Deferred) (Transaction, error) {
var tx msig12.Transaction
if err := tx.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return Transaction{}, err
}
return Transaction(tx), nil
}
func (s *state12) GetState() interface{} {
return &s.State
}
func (s *state12) ActorKey() string {
return manifest.MultisigKey
}
func (s *state12) ActorVersion() actorstypes.Version {
return actorstypes.Version12
}
func (s *state12) 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
}

109
chain/actors/builtin/paych/message12.go generated Normal file
View File

@ -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"
builtin12 "github.com/filecoin-project/go-state-types/builtin"
init12 "github.com/filecoin-project/go-state-types/builtin/v12/init"
paych12 "github.com/filecoin-project/go-state-types/builtin/v12/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 message12 struct{ from address.Address }
func (m message12) Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error) {
actorCodeID, ok := actors.GetActorCodeID(actorstypes.Version12, "paymentchannel")
if !ok {
return nil, xerrors.Errorf("error getting actor paymentchannel code id for actor version %d", 12)
}
params, aerr := actors.SerializeParams(&paych12.ConstructorParams{From: m.from, To: to})
if aerr != nil {
return nil, aerr
}
enc, aerr := actors.SerializeParams(&init12.ExecParams{
CodeCID: actorCodeID,
ConstructorParams: params,
})
if aerr != nil {
return nil, aerr
}
return &types.Message{
To: init_.Address,
From: m.from,
Value: initialAmount,
Method: builtin12.MethodsInit.Exec,
Params: enc,
}, nil
}
func (m message12) Update(paych address.Address, sv *paychtypes.SignedVoucher, secret []byte) (*types.Message, error) {
params, aerr := actors.SerializeParams(&paych12.UpdateChannelStateParams{
Sv: toV12SignedVoucher(*sv),
Secret: secret,
})
if aerr != nil {
return nil, aerr
}
return &types.Message{
To: paych,
From: m.from,
Value: abi.NewTokenAmount(0),
Method: builtin12.MethodsPaych.UpdateChannelState,
Params: params,
}, nil
}
func toV12SignedVoucher(sv paychtypes.SignedVoucher) paych12.SignedVoucher {
merges := make([]paych12.Merge, len(sv.Merges))
for i := range sv.Merges {
merges[i] = paych12.Merge{
Lane: sv.Merges[i].Lane,
Nonce: sv.Merges[i].Nonce,
}
}
return paych12.SignedVoucher{
ChannelAddr: sv.ChannelAddr,
TimeLockMin: sv.TimeLockMin,
TimeLockMax: sv.TimeLockMax,
SecretHash: sv.SecretHash,
Extra: (*paych12.ModVerifyParams)(sv.Extra),
Lane: sv.Lane,
Nonce: sv.Nonce,
Amount: sv.Amount,
MinSettleHeight: sv.MinSettleHeight,
Merges: merges,
Signature: sv.Signature,
}
}
func (m message12) Settle(paych address.Address) (*types.Message, error) {
return &types.Message{
To: paych,
From: m.from,
Value: abi.NewTokenAmount(0),
Method: builtin12.MethodsPaych.Settle,
}, nil
}
func (m message12) Collect(paych address.Address) (*types.Message, error) {
return &types.Message{
To: paych,
From: m.from,
Value: abi.NewTokenAmount(0),
Method: builtin12.MethodsPaych.Collect,
}, nil
}

View File

@ -50,6 +50,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
case actorstypes.Version11:
return load11(store, act.Head)
case actorstypes.Version12:
return load12(store, act.Head)
}
}
@ -167,6 +170,9 @@ func Message(version actorstypes.Version, from address.Address) MessageBuilder {
case actorstypes.Version11:
return message11{from}
case actorstypes.Version12:
return message12{from}
default:
panic(fmt.Sprintf("unsupported actors version: %d", version))
}
@ -208,5 +214,6 @@ func AllCodes() []cid.Cid {
(&state9{}).Code(),
(&state10{}).Code(),
(&state11{}).Code(),
(&state12{}).Code(),
}
}

135
chain/actors/builtin/paych/v12.go generated Normal file
View File

@ -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"
paych12 "github.com/filecoin-project/go-state-types/builtin/v12/paych"
adt12 "github.com/filecoin-project/go-state-types/builtin/v12/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 = (*state12)(nil)
func load12(store adt.Store, root cid.Cid) (State, error) {
out := state12{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make12(store adt.Store) (State, error) {
out := state12{store: store}
out.State = paych12.State{}
return &out, nil
}
type state12 struct {
paych12.State
store adt.Store
lsAmt *adt12.Array
}
// Channel owner, who has funded the actor
func (s *state12) From() (address.Address, error) {
return s.State.From, nil
}
// Recipient of payouts from channel
func (s *state12) To() (address.Address, error) {
return s.State.To, nil
}
// Height at which the channel can be `Collected`
func (s *state12) SettlingAt() (abi.ChainEpoch, error) {
return s.State.SettlingAt, nil
}
// Amount successfully redeemed through the payment channel, paid out on `Collect()`
func (s *state12) ToSend() (abi.TokenAmount, error) {
return s.State.ToSend, nil
}
func (s *state12) getOrLoadLsAmt() (*adt12.Array, error) {
if s.lsAmt != nil {
return s.lsAmt, nil
}
// Get the lane state from the chain
lsamt, err := adt12.AsArray(s.store, s.State.LaneStates, paych12.LaneStatesAmtBitwidth)
if err != nil {
return nil, err
}
s.lsAmt = lsamt
return lsamt, nil
}
// Get total number of lanes
func (s *state12) LaneCount() (uint64, error) {
lsamt, err := s.getOrLoadLsAmt()
if err != nil {
return 0, err
}
return lsamt.Length(), nil
}
func (s *state12) GetState() interface{} {
return &s.State
}
// Iterate lane states
func (s *state12) 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 paych12.LaneState
return lsamt.ForEach(&ls, func(i int64) error {
return cb(uint64(i), &laneState12{ls})
})
}
type laneState12 struct {
paych12.LaneState
}
func (ls *laneState12) Redeemed() (big.Int, error) {
return ls.LaneState.Redeemed, nil
}
func (ls *laneState12) Nonce() (uint64, error) {
return ls.LaneState.Nonce, nil
}
func (s *state12) ActorKey() string {
return manifest.PaychKey
}
func (s *state12) ActorVersion() actorstypes.Version {
return actorstypes.Version12
}
func (s *state12) 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
}

View File

@ -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"
builtin11 "github.com/filecoin-project/go-state-types/builtin"
builtin12 "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 = builtin11.StoragePowerActorAddr
Methods = builtin11.MethodsPower
Address = builtin12.StoragePowerActorAddr
Methods = builtin12.MethodsPower
)
func Load(store adt.Store, act *types.Actor) (State, error) {
@ -51,6 +51,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
case actorstypes.Version11:
return load11(store, act.Head)
case actorstypes.Version12:
return load12(store, act.Head)
}
}
@ -118,6 +121,9 @@ func MakeState(store adt.Store, av actorstypes.Version) (State, error) {
case actorstypes.Version11:
return make11(store)
case actorstypes.Version12:
return make12(store)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
@ -183,5 +189,6 @@ func AllCodes() []cid.Cid {
(&state9{}).Code(),
(&state10{}).Code(),
(&state11{}).Code(),
(&state12{}).Code(),
}
}

207
chain/actors/builtin/power/v12.go generated Normal file
View File

@ -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"
builtin12 "github.com/filecoin-project/go-state-types/builtin"
power12 "github.com/filecoin-project/go-state-types/builtin/v12/power"
adt12 "github.com/filecoin-project/go-state-types/builtin/v12/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 = (*state12)(nil)
func load12(store adt.Store, root cid.Cid) (State, error) {
out := state12{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make12(store adt.Store) (State, error) {
out := state12{store: store}
s, err := power12.ConstructState(store)
if err != nil {
return nil, err
}
out.State = *s
return &out, nil
}
type state12 struct {
power12.State
store adt.Store
}
func (s *state12) TotalLocked() (abi.TokenAmount, error) {
return s.TotalPledgeCollateral, nil
}
func (s *state12) 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 *state12) TotalCommitted() (Claim, error) {
return Claim{
RawBytePower: s.TotalBytesCommitted,
QualityAdjPower: s.TotalQABytesCommitted,
}, nil
}
func (s *state12) MinerPower(addr address.Address) (Claim, bool, error) {
claims, err := s.claims()
if err != nil {
return Claim{}, false, err
}
var claim power12.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 *state12) MinerNominalPowerMeetsConsensusMinimum(a address.Address) (bool, error) {
return s.State.MinerNominalPowerMeetsConsensusMinimum(s.store, a)
}
func (s *state12) TotalPowerSmoothed() (builtin.FilterEstimate, error) {
return builtin.FilterEstimate(s.State.ThisEpochQAPowerSmoothed), nil
}
func (s *state12) MinerCounts() (uint64, uint64, error) {
return uint64(s.State.MinerAboveMinPowerCount), uint64(s.State.MinerCount), nil
}
func (s *state12) 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 *state12) ForEachClaim(cb func(miner address.Address, claim Claim) error) error {
claims, err := s.claims()
if err != nil {
return err
}
var claim power12.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 *state12) ClaimsChanged(other State) (bool, error) {
other12, ok := other.(*state12)
if !ok {
// treat an upgrade as a change, always
return true, nil
}
return !s.State.Claims.Equals(other12.State.Claims), nil
}
func (s *state12) SetTotalQualityAdjPower(p abi.StoragePower) error {
s.State.TotalQualityAdjPower = p
return nil
}
func (s *state12) SetTotalRawBytePower(p abi.StoragePower) error {
s.State.TotalRawBytePower = p
return nil
}
func (s *state12) SetThisEpochQualityAdjPower(p abi.StoragePower) error {
s.State.ThisEpochQualityAdjPower = p
return nil
}
func (s *state12) SetThisEpochRawBytePower(p abi.StoragePower) error {
s.State.ThisEpochRawBytePower = p
return nil
}
func (s *state12) GetState() interface{} {
return &s.State
}
func (s *state12) claims() (adt.Map, error) {
return adt12.AsMap(s.store, s.Claims, builtin12.DefaultHamtBitwidth)
}
func (s *state12) decodeClaim(val *cbg.Deferred) (Claim, error) {
var ci power12.Claim
if err := ci.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return Claim{}, err
}
return fromV12Claim(ci), nil
}
func fromV12Claim(v12 power12.Claim) Claim {
return Claim{
RawBytePower: v12.RawBytePower,
QualityAdjPower: v12.QualityAdjPower,
}
}
func (s *state12) ActorKey() string {
return manifest.PowerKey
}
func (s *state12) ActorVersion() actorstypes.Version {
return actorstypes.Version12
}
func (s *state12) 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
}

View File

@ -42,6 +42,22 @@ import (
reward11 "github.com/filecoin-project/go-state-types/builtin/v11/reward"
system11 "github.com/filecoin-project/go-state-types/builtin/v11/system"
verifreg11 "github.com/filecoin-project/go-state-types/builtin/v11/verifreg"
account12 "github.com/filecoin-project/go-state-types/builtin/v12/account"
cron12 "github.com/filecoin-project/go-state-types/builtin/v12/cron"
datacap12 "github.com/filecoin-project/go-state-types/builtin/v12/datacap"
eam12 "github.com/filecoin-project/go-state-types/builtin/v12/eam"
ethaccount12 "github.com/filecoin-project/go-state-types/builtin/v12/ethaccount"
evm12 "github.com/filecoin-project/go-state-types/builtin/v12/evm"
_init12 "github.com/filecoin-project/go-state-types/builtin/v12/init"
market12 "github.com/filecoin-project/go-state-types/builtin/v12/market"
miner12 "github.com/filecoin-project/go-state-types/builtin/v12/miner"
multisig12 "github.com/filecoin-project/go-state-types/builtin/v12/multisig"
paych12 "github.com/filecoin-project/go-state-types/builtin/v12/paych"
placeholder12 "github.com/filecoin-project/go-state-types/builtin/v12/placeholder"
power12 "github.com/filecoin-project/go-state-types/builtin/v12/power"
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"
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"
@ -497,6 +513,110 @@ func MakeRegistry(av actorstypes.Version) []RegistryEntry {
}
}
case actorstypes.Version12:
for key, codeID := range codeIDs {
switch key {
case manifest.AccountKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: account12.Methods,
state: new(account12.State),
})
case manifest.CronKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: cron12.Methods,
state: new(cron12.State),
})
case manifest.InitKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: _init12.Methods,
state: new(_init12.State),
})
case manifest.MarketKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: market12.Methods,
state: new(market12.State),
})
case manifest.MinerKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: miner12.Methods,
state: new(miner12.State),
})
case manifest.MultisigKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: multisig12.Methods,
state: new(multisig12.State),
})
case manifest.PaychKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: paych12.Methods,
state: new(paych12.State),
})
case manifest.PowerKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: power12.Methods,
state: new(power12.State),
})
case manifest.RewardKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: reward12.Methods,
state: new(reward12.State),
})
case manifest.SystemKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: system12.Methods,
state: new(system12.State),
})
case manifest.VerifregKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: verifreg12.Methods,
state: new(verifreg12.State),
})
case manifest.DatacapKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: datacap12.Methods,
state: new(datacap12.State),
})
case manifest.EvmKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: evm12.Methods,
state: new(evm12.State),
})
case manifest.EamKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: eam12.Methods,
state: nil,
})
case manifest.PlaceholderKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: placeholder12.Methods,
state: nil,
})
case manifest.EthAccountKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: ethaccount12.Methods,
state: nil,
})
}
}
default:
panic("expected version v8 and up only, use specs-actors for v0-7")
}

View File

@ -6,7 +6,7 @@ import (
"github.com/filecoin-project/go-state-types/abi"
actorstypes "github.com/filecoin-project/go-state-types/actors"
builtin11 "github.com/filecoin-project/go-state-types/builtin"
builtin12 "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 = builtin11.RewardActorAddr
Methods = builtin11.MethodsReward
Address = builtin12.RewardActorAddr
Methods = builtin12.MethodsReward
)
func Load(store adt.Store, act *types.Actor) (State, error) {
@ -49,6 +49,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
case actorstypes.Version11:
return load11(store, act.Head)
case actorstypes.Version12:
return load12(store, act.Head)
}
}
@ -116,6 +119,9 @@ func MakeState(store adt.Store, av actorstypes.Version, currRealizedPower abi.St
case actorstypes.Version11:
return make11(store, currRealizedPower)
case actorstypes.Version12:
return make12(store, currRealizedPower)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
@ -159,5 +165,6 @@ func AllCodes() []cid.Cid {
(&state9{}).Code(),
(&state10{}).Code(),
(&state11{}).Code(),
(&state12{}).Code(),
}
}

120
chain/actors/builtin/reward/v12.go generated Normal file
View File

@ -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"
miner12 "github.com/filecoin-project/go-state-types/builtin/v12/miner"
reward12 "github.com/filecoin-project/go-state-types/builtin/v12/reward"
smoothing12 "github.com/filecoin-project/go-state-types/builtin/v12/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 = (*state12)(nil)
func load12(store adt.Store, root cid.Cid) (State, error) {
out := state12{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make12(store adt.Store, currRealizedPower abi.StoragePower) (State, error) {
out := state12{store: store}
out.State = *reward12.ConstructState(currRealizedPower)
return &out, nil
}
type state12 struct {
reward12.State
store adt.Store
}
func (s *state12) ThisEpochReward() (abi.TokenAmount, error) {
return s.State.ThisEpochReward, nil
}
func (s *state12) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) {
return builtin.FilterEstimate{
PositionEstimate: s.State.ThisEpochRewardSmoothed.PositionEstimate,
VelocityEstimate: s.State.ThisEpochRewardSmoothed.VelocityEstimate,
}, nil
}
func (s *state12) ThisEpochBaselinePower() (abi.StoragePower, error) {
return s.State.ThisEpochBaselinePower, nil
}
func (s *state12) TotalStoragePowerReward() (abi.TokenAmount, error) {
return s.State.TotalStoragePowerReward, nil
}
func (s *state12) EffectiveBaselinePower() (abi.StoragePower, error) {
return s.State.EffectiveBaselinePower, nil
}
func (s *state12) EffectiveNetworkTime() (abi.ChainEpoch, error) {
return s.State.EffectiveNetworkTime, nil
}
func (s *state12) CumsumBaseline() (reward12.Spacetime, error) {
return s.State.CumsumBaseline, nil
}
func (s *state12) CumsumRealized() (reward12.Spacetime, error) {
return s.State.CumsumRealized, nil
}
func (s *state12) InitialPledgeForPower(qaPower abi.StoragePower, networkTotalPledge abi.TokenAmount, networkQAPower *builtin.FilterEstimate, circSupply abi.TokenAmount) (abi.TokenAmount, error) {
return miner12.InitialPledgeForPower(
qaPower,
s.State.ThisEpochBaselinePower,
s.State.ThisEpochRewardSmoothed,
smoothing12.FilterEstimate{
PositionEstimate: networkQAPower.PositionEstimate,
VelocityEstimate: networkQAPower.VelocityEstimate,
},
circSupply,
), nil
}
func (s *state12) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate, sectorWeight abi.StoragePower) (abi.TokenAmount, error) {
return miner12.PreCommitDepositForPower(s.State.ThisEpochRewardSmoothed,
smoothing12.FilterEstimate{
PositionEstimate: networkQAPower.PositionEstimate,
VelocityEstimate: networkQAPower.VelocityEstimate,
},
sectorWeight), nil
}
func (s *state12) GetState() interface{} {
return &s.State
}
func (s *state12) ActorKey() string {
return manifest.RewardKey
}
func (s *state12) ActorVersion() actorstypes.Version {
return actorstypes.Version12
}
func (s *state12) 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
}

View File

@ -5,7 +5,7 @@ import (
"golang.org/x/xerrors"
actorstypes "github.com/filecoin-project/go-state-types/actors"
builtin11 "github.com/filecoin-project/go-state-types/builtin"
builtin12 "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 = builtin11.SystemActorAddr
Address = builtin12.SystemActorAddr
)
func Load(store adt.Store, act *types.Actor) (State, error) {
@ -44,6 +44,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
case actorstypes.Version11:
return load11(store, act.Head)
case actorstypes.Version12:
return load12(store, act.Head)
}
}
@ -111,6 +114,9 @@ func MakeState(store adt.Store, av actorstypes.Version, builtinActors cid.Cid) (
case actorstypes.Version11:
return make11(store, builtinActors)
case actorstypes.Version12:
return make12(store, builtinActors)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
@ -138,5 +144,6 @@ func AllCodes() []cid.Cid {
(&state9{}).Code(),
(&state10{}).Code(),
(&state11{}).Code(),
(&state12{}).Code(),
}
}

72
chain/actors/builtin/system/v12.go generated Normal file
View File

@ -0,0 +1,72 @@
package system
import (
"fmt"
"github.com/ipfs/go-cid"
actorstypes "github.com/filecoin-project/go-state-types/actors"
system12 "github.com/filecoin-project/go-state-types/builtin/v12/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 = (*state12)(nil)
func load12(store adt.Store, root cid.Cid) (State, error) {
out := state12{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make12(store adt.Store, builtinActors cid.Cid) (State, error) {
out := state12{store: store}
out.State = system12.State{
BuiltinActors: builtinActors,
}
return &out, nil
}
type state12 struct {
system12.State
store adt.Store
}
func (s *state12) GetState() interface{} {
return &s.State
}
func (s *state12) GetBuiltinActors() cid.Cid {
return s.State.BuiltinActors
}
func (s *state12) SetBuiltinActors(c cid.Cid) error {
s.State.BuiltinActors = c
return nil
}
func (s *state12) ActorKey() string {
return manifest.SystemKey
}
func (s *state12) ActorVersion() actorstypes.Version {
return actorstypes.Version12
}
func (s *state12) 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
}

170
chain/actors/builtin/verifreg/v12.go generated Normal file
View File

@ -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"
builtin12 "github.com/filecoin-project/go-state-types/builtin"
adt12 "github.com/filecoin-project/go-state-types/builtin/v12/util/adt"
verifreg12 "github.com/filecoin-project/go-state-types/builtin/v12/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 = (*state12)(nil)
func load12(store adt.Store, root cid.Cid) (State, error) {
out := state12{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make12(store adt.Store, rootKeyAddress address.Address) (State, error) {
out := state12{store: store}
s, err := verifreg12.ConstructState(store, rootKeyAddress)
if err != nil {
return nil, err
}
out.State = *s
return &out, nil
}
type state12 struct {
verifreg12.State
store adt.Store
}
func (s *state12) RootKey() (address.Address, error) {
return s.State.RootKey, nil
}
func (s *state12) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) {
return false, big.Zero(), xerrors.Errorf("unsupported in actors v12")
}
func (s *state12) VerifierDataCap(addr address.Address) (bool, abi.StoragePower, error) {
return getDataCap(s.store, actors.Version12, s.verifiers, addr)
}
func (s *state12) RemoveDataCapProposalID(verifier address.Address, client address.Address) (bool, uint64, error) {
return getRemoveDataCapProposalID(s.store, actors.Version12, s.removeDataCapProposalIDs, verifier, client)
}
func (s *state12) ForEachVerifier(cb func(addr address.Address, dcap abi.StoragePower) error) error {
return forEachCap(s.store, actors.Version12, s.verifiers, cb)
}
func (s *state12) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error {
return xerrors.Errorf("unsupported in actors v12")
}
func (s *state12) verifiedClients() (adt.Map, error) {
return nil, xerrors.Errorf("unsupported in actors v12")
}
func (s *state12) verifiers() (adt.Map, error) {
return adt12.AsMap(s.store, s.Verifiers, builtin12.DefaultHamtBitwidth)
}
func (s *state12) removeDataCapProposalIDs() (adt.Map, error) {
return adt12.AsMap(s.store, s.RemoveDataCapProposalIDs, builtin12.DefaultHamtBitwidth)
}
func (s *state12) GetState() interface{} {
return &s.State
}
func (s *state12) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*Allocation, bool, error) {
alloc, ok, err := s.FindAllocation(s.store, clientIdAddr, verifreg12.AllocationId(allocationId))
return (*Allocation)(alloc), ok, err
}
func (s *state12) GetAllocations(clientIdAddr address.Address) (map[AllocationId]Allocation, error) {
v12Map, err := s.LoadAllocationsToMap(s.store, clientIdAddr)
retMap := make(map[AllocationId]Allocation, len(v12Map))
for k, v := range v12Map {
retMap[AllocationId(k)] = Allocation(v)
}
return retMap, err
}
func (s *state12) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*Claim, bool, error) {
claim, ok, err := s.FindClaim(s.store, providerIdAddr, verifreg12.ClaimId(claimId))
return (*Claim)(claim), ok, err
}
func (s *state12) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, error) {
v12Map, err := s.LoadClaimsToMap(s.store, providerIdAddr)
retMap := make(map[ClaimId]Claim, len(v12Map))
for k, v := range v12Map {
retMap[ClaimId(k)] = Claim(v)
}
return retMap, err
}
func (s *state12) GetClaimIdsBySector(providerIdAddr address.Address) (map[abi.SectorNumber][]ClaimId, error) {
v12Map, err := s.LoadClaimsToMap(s.store, providerIdAddr)
retMap := make(map[abi.SectorNumber][]ClaimId)
for k, v := range v12Map {
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 *state12) ActorKey() string {
return manifest.VerifregKey
}
func (s *state12) ActorVersion() actorstypes.Version {
return actorstypes.Version12
}
func (s *state12) 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
}

View File

@ -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"
builtin11 "github.com/filecoin-project/go-state-types/builtin"
builtin12 "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 = builtin11.VerifiedRegistryActorAddr
Methods = builtin11.MethodsVerifiedRegistry
Address = builtin12.VerifiedRegistryActorAddr
Methods = builtin12.MethodsVerifiedRegistry
)
func Load(store adt.Store, act *types.Actor) (State, error) {
@ -49,6 +49,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
case actorstypes.Version11:
return load11(store, act.Head)
case actorstypes.Version12:
return load12(store, act.Head)
}
}
@ -116,6 +119,9 @@ func MakeState(store adt.Store, av actorstypes.Version, rootKeyAddress address.A
case actorstypes.Version11:
return make11(store, rootKeyAddress)
case actorstypes.Version12:
return make12(store, rootKeyAddress)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
@ -154,6 +160,7 @@ func AllCodes() []cid.Cid {
(&state9{}).Code(),
(&state10{}).Code(),
(&state11{}).Code(),
(&state12{}).Code(),
}
}

View File

@ -8,6 +8,7 @@ import (
"github.com/filecoin-project/go-state-types/big"
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"
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"
@ -15,8 +16,11 @@ import (
verifreg10 "github.com/filecoin-project/go-state-types/builtin/v10/verifreg"
market11 "github.com/filecoin-project/go-state-types/builtin/v11/market"
miner11 "github.com/filecoin-project/go-state-types/builtin/v11/miner"
paych11 "github.com/filecoin-project/go-state-types/builtin/v11/paych"
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"
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"
@ -55,14 +59,14 @@ import (
)
const (
ChainFinality = miner11.ChainFinality
ChainFinality = miner12.ChainFinality
SealRandomnessLookback = ChainFinality
PaychSettleDelay = paych11.SettleDelay
MaxPreCommitRandomnessLookback = builtin11.EpochsInDay + SealRandomnessLookback
PaychSettleDelay = paych12.SettleDelay
MaxPreCommitRandomnessLookback = builtin12.EpochsInDay + SealRandomnessLookback
)
var (
MarketDefaultAllocationTermBuffer = market11.MarketDefaultAllocationTermBuffer
MarketDefaultAllocationTermBuffer = market12.MarketDefaultAllocationTermBuffer
)
// SetSupportedProofTypes sets supported proof types, across all actor versions.
@ -175,11 +179,13 @@ func SetPreCommitChallengeDelay(delay abi.ChainEpoch) {
miner11.PreCommitChallengeDelay = delay
miner12.PreCommitChallengeDelay = delay
}
// TODO: this function shouldn't really exist. Instead, the API should expose the precommit delay.
func GetPreCommitChallengeDelay() abi.ChainEpoch {
return miner11.PreCommitChallengeDelay
return miner12.PreCommitChallengeDelay
}
// SetConsensusMinerMinPower sets the minimum power of an individual miner must
@ -229,6 +235,10 @@ func SetConsensusMinerMinPower(p abi.StoragePower) {
policy.ConsensusMinerMinPower = p
}
for _, policy := range builtin12.PoStProofPolicies {
policy.ConsensusMinerMinPower = p
}
}
// SetMinVerifiedDealSize sets the minimum size of a verified deal. This should
@ -257,6 +267,8 @@ func SetMinVerifiedDealSize(size abi.StoragePower) {
verifreg11.MinVerifiedDealSize = size
verifreg12.MinVerifiedDealSize = size
}
func GetMaxProveCommitDuration(ver actorstypes.Version, t abi.RegisteredSealProof) (abi.ChainEpoch, error) {
@ -306,6 +318,10 @@ func GetMaxProveCommitDuration(ver actorstypes.Version, t abi.RegisteredSealProo
return miner11.MaxProveCommitDuration[t], nil
case actorstypes.Version12:
return miner12.MaxProveCommitDuration[t], nil
default:
return 0, xerrors.Errorf("unsupported actors version")
}
@ -366,6 +382,11 @@ func SetProviderCollateralSupplyTarget(num, denom big.Int) {
Denominator: denom,
}
market12.ProviderCollateralSupplyTarget = builtin12.BigFrac{
Numerator: num,
Denominator: denom,
}
}
func DealProviderCollateralBounds(
@ -434,13 +455,18 @@ func DealProviderCollateralBounds(
min, max := market11.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil)
return min, max, nil
case actorstypes.Version12:
min, max := market12.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 market11.DealDurationBounds(pieceSize)
return market12.DealDurationBounds(pieceSize)
}
// Sets the challenge window and scales the proving period to match (such that
@ -516,6 +542,13 @@ func SetWPoStChallengeWindow(period abi.ChainEpoch) {
// scale it if we're scaling the challenge period.
miner11.WPoStDisputeWindow = period * 30
miner12.WPoStChallengeWindow = period
miner12.WPoStProvingPeriod = period * abi.ChainEpoch(miner12.WPoStPeriodDeadlines)
// by default, this is 2x finality which is 30 periods.
// scale it if we're scaling the challenge period.
miner12.WPoStDisputeWindow = period * 30
}
func GetWinningPoStSectorSetLookback(nwVer network.Version) abi.ChainEpoch {
@ -528,15 +561,15 @@ func GetWinningPoStSectorSetLookback(nwVer network.Version) abi.ChainEpoch {
}
func GetMaxSectorExpirationExtension() abi.ChainEpoch {
return miner11.MaxSectorExpirationExtension
return miner12.MaxSectorExpirationExtension
}
func GetMinSectorExpiration() abi.ChainEpoch {
return miner11.MinSectorExpiration
return miner12.MinSectorExpiration
}
func GetMaxPoStPartitions(nv network.Version, p abi.RegisteredPoStProof) (int, error) {
sectorsPerPart, err := builtin11.PoStProofWindowPoStPartitionSectors(p)
sectorsPerPart, err := builtin12.PoStProofWindowPoStPartitionSectors(p)
if err != nil {
return 0, err
}
@ -556,7 +589,7 @@ func GetSectorMaxLifetime(proof abi.RegisteredSealProof, nwVer network.Version)
return builtin4.SealProofPoliciesV0[proof].SectorMaxLifetime
}
return builtin11.SealProofPoliciesV11[proof].SectorMaxLifetime
return builtin12.SealProofPoliciesV11[proof].SectorMaxLifetime
}
func GetAddressedSectorsMax(nwVer network.Version) (int, error) {
@ -599,6 +632,9 @@ func GetAddressedSectorsMax(nwVer network.Version) (int, error) {
case actorstypes.Version11:
return miner11.AddressedSectorsMax, nil
case actorstypes.Version12:
return miner12.AddressedSectorsMax, nil
default:
return 0, xerrors.Errorf("unsupported network version")
}
@ -656,6 +692,10 @@ func GetDeclarationsMax(nwVer network.Version) (int, error) {
return miner11.DeclarationsMax, nil
case actorstypes.Version12:
return miner12.DeclarationsMax, nil
default:
return 0, xerrors.Errorf("unsupported network version")
}
@ -712,6 +752,10 @@ func AggregateProveCommitNetworkFee(nwVer network.Version, aggregateSize int, ba
return miner11.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil
case actorstypes.Version12:
return miner12.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil
default:
return big.Zero(), xerrors.Errorf("unsupported network version")
}
@ -768,6 +812,10 @@ func AggregatePreCommitNetworkFee(nwVer network.Version, aggregateSize int, base
return miner11.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil
case actorstypes.Version12:
return miner12.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil
default:
return big.Zero(), xerrors.Errorf("unsupported network version")
}

View File

@ -14,9 +14,9 @@ const ({{range .actorVersions}}
/* inline-gen start */
var LatestVersion = 11
var LatestVersion = 12
var Versions = []int{0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
var Versions = []int{0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
const (
Version0 Version = 0
@ -30,6 +30,7 @@ const (
Version9 Version = 9
Version10 Version = 10
Version11 Version = 11
Version12 Version = 12
)
/* inline-gen end */

View File

@ -52,6 +52,7 @@ func NewActorRegistry() *vm.ActorRegistry {
inv.Register(actorstypes.Version9, vm.ActorsVersionPredicate(actorstypes.Version9), builtin.MakeRegistry(actorstypes.Version9))
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))
return inv
}

View File

@ -20,6 +20,7 @@ import (
"github.com/filecoin-project/go-state-types/big"
nv18 "github.com/filecoin-project/go-state-types/builtin/v10/migration"
nv19 "github.com/filecoin-project/go-state-types/builtin/v11/migration"
nv21 "github.com/filecoin-project/go-state-types/builtin/v12/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"
@ -261,6 +262,17 @@ func DefaultUpgradeSchedule() stmgr.UpgradeSchedule {
Height: build.UpgradeThunderHeight,
Network: network.Version20,
Migration: nil,
}, {
Height: build.UpgradeWatermelonHeight,
Network: network.Version21,
Migration: UpgradeActorsV12,
PreMigrations: []stmgr.PreMigration{{
PreMigration: PreUpgradeActorsV12,
StartWithin: 120,
DontStartWithin: 15,
StopWithin: 10,
}},
Expensive: true,
},
}
@ -1814,6 +1826,108 @@ func upgradeActorsV11Common(
return newRoot, nil
}
func PreUpgradeActorsV12(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 = upgradeActorsV12Common(ctx, sm, cache, lbRoot, epoch, lbts, config)
return err
}
func UpgradeActorsV12(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 := upgradeActorsV12Common(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 upgradeActorsV12Common(
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.Version12); 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 v12 upgrade, got %d",
stateRoot.Version,
)
}
manifest, ok := actors.GetManifest(actorstypes.Version12)
if !ok {
return cid.Undef, xerrors.Errorf("no manifest CID for v12 upgrade")
}
// Perform the migration
newHamtRoot, err := nv21.MigrateStateTree(ctx, adtStore, manifest, stateRoot.Actors, epoch, config,
migrationLogger{}, cache)
if err != nil {
return cid.Undef, xerrors.Errorf("upgrading to actors v12: %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
//func UpgradeActorsV9(ctx context.Context, sm *stmgr.StateManager, _ stmgr.MigrationCache, _ stmgr.ExecMonitor, root cid.Cid, _ abi.ChainEpoch, _ *types.TipSet) (cid.Cid, error) {
// buf := blockstore.NewTieredBstore(sm.ChainStore().StateBlockstore(), blockstore.NewMemorySync())

View File

@ -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:
case network.Version18, network.Version19, network.Version20, network.Version21:
return types.StateTreeVersion5, nil
default:

View File

@ -475,7 +475,7 @@ Inputs:
],
"Bw==",
10101,
20
21
]
```

View File

@ -4729,7 +4729,7 @@ Perms: read
Inputs:
```json
[
20
21
]
```
@ -4744,7 +4744,7 @@ Perms: read
Inputs:
```json
[
20
21
]
```
@ -5445,7 +5445,8 @@ Response:
"UpgradeSharkHeight": 10101,
"UpgradeHyggeHeight": 10101,
"UpgradeLightningHeight": 10101,
"UpgradeThunderHeight": 10101
"UpgradeThunderHeight": 10101,
"UpgradeWatermelonHeight": 10101
}
}
```
@ -6370,7 +6371,7 @@ Inputs:
]
```
Response: `20`
Response: `21`
### StateReadState
StateReadState returns the indicated actor's state.

View File

@ -6166,7 +6166,7 @@ Perms: read
Inputs:
```json
[
20
21
]
```
@ -6181,7 +6181,7 @@ Perms: read
Inputs:
```json
[
20
21
]
```
@ -6957,7 +6957,8 @@ Response:
"UpgradeSharkHeight": 10101,
"UpgradeHyggeHeight": 10101,
"UpgradeLightningHeight": 10101,
"UpgradeThunderHeight": 10101
"UpgradeThunderHeight": 10101,
"UpgradeWatermelonHeight": 10101
}
}
```
@ -7890,7 +7891,7 @@ Inputs:
]
```
Response: `20`
Response: `21`
### StateReadState
StateReadState returns the indicated actor's state.

View File

@ -1,7 +1,7 @@
{
"actorVersions": [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
"latestActorsVersion": 11,
"actorVersions": [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
"latestActorsVersion": 12,
"networkVersions": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],
"latestNetworkVersion": 20
"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
}

2
go.mod
View File

@ -338,3 +338,5 @@ require (
replace github.com/filecoin-project/filecoin-ffi => ./extern/filecoin-ffi
replace github.com/filecoin-project/test-vectors => ./extern/test-vectors
replace github.com/filecoin-project/go-state-types => /Users/phi/go-state-types

View File

@ -49,12 +49,12 @@ func LatestActorsAt(upgradeHeight abi.ChainEpoch) EnsembleOpt {
})
/* inline-gen start */
return UpgradeSchedule(stmgr.Upgrade{
Network: network.Version19,
Network: network.Version20,
Height: -1,
}, stmgr.Upgrade{
Network: network.Version20,
Network: network.Version21,
Height: upgradeHeight,
Migration: filcns.UpgradeActorsV11,
Migration: filcns.UpgradeActorsV12,
})
/* inline-gen end */
}

View File

@ -1811,6 +1811,7 @@ func (a *StateAPI) StateGetNetworkParams(ctx context.Context) (*api.NetworkParam
UpgradeHyggeHeight: build.UpgradeHyggeHeight,
UpgradeLightningHeight: build.UpgradeLightningHeight,
UpgradeThunderHeight: build.UpgradeThunderHeight,
UpgradeWatermelonHeight: build.UpgradeWatermelonHeight,
},
}, nil
}