Merge pull request #9267 from filecoin-project/jen/nv17

feat: network: add nv17 and integrate the corresponding go state type
This commit is contained in:
Aayush Rajasekaran 2022-09-12 18:19:28 -04:00 committed by GitHub
commit 04a8239df4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
198 changed files with 4959 additions and 1851 deletions

View File

@ -18,8 +18,8 @@ import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/builtin/v8/market"
"github.com/filecoin-project/go-state-types/builtin/v8/miner"
"github.com/filecoin-project/go-state-types/builtin/v8/paych"
"github.com/filecoin-project/go-state-types/builtin/v9/miner"
"github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/go-state-types/dline"
abinetwork "github.com/filecoin-project/go-state-types/network"

View File

@ -8,7 +8,7 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/builtin/v8/miner"
"github.com/filecoin-project/go-state-types/builtin/v9/miner"
"github.com/filecoin-project/go-state-types/dline"
apitypes "github.com/filecoin-project/lotus/api/types"

View File

@ -18,7 +18,7 @@ import (
"github.com/filecoin-project/go-jsonrpc/auth"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/builtin/v8/market"
"github.com/filecoin-project/go-state-types/builtin/v8/miner"
"github.com/filecoin-project/go-state-types/builtin/v9/miner"
abinetwork "github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/lotus/chain/actors/builtin"

View File

@ -26,8 +26,8 @@ import (
auth "github.com/filecoin-project/go-jsonrpc/auth"
abi "github.com/filecoin-project/go-state-types/abi"
big "github.com/filecoin-project/go-state-types/big"
miner "github.com/filecoin-project/go-state-types/builtin/v8/miner"
paych "github.com/filecoin-project/go-state-types/builtin/v8/paych"
miner "github.com/filecoin-project/go-state-types/builtin/v9/miner"
crypto "github.com/filecoin-project/go-state-types/crypto"
dline "github.com/filecoin-project/go-state-types/dline"
network "github.com/filecoin-project/go-state-types/network"

View File

@ -24,8 +24,8 @@ import (
"github.com/filecoin-project/go-fil-markets/storagemarket"
"github.com/filecoin-project/go-jsonrpc/auth"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/builtin/v8/miner"
"github.com/filecoin-project/go-state-types/builtin/v8/paych"
"github.com/filecoin-project/go-state-types/builtin/v9/miner"
"github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/go-state-types/dline"
abinetwork "github.com/filecoin-project/go-state-types/network"

View File

@ -14,8 +14,8 @@ import (
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
"github.com/filecoin-project/go-fil-markets/storagemarket"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/builtin/v8/miner"
"github.com/filecoin-project/go-state-types/builtin/v8/paych"
"github.com/filecoin-project/go-state-types/builtin/v9/miner"
"github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/go-state-types/dline"
abinetwork "github.com/filecoin-project/go-state-types/network"

View File

@ -8,7 +8,7 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/builtin/v8/miner"
"github.com/filecoin-project/go-state-types/builtin/v9/miner"
"github.com/filecoin-project/go-state-types/dline"
abinetwork "github.com/filecoin-project/go-state-types/network"

View File

@ -16,8 +16,8 @@ import (
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
"github.com/filecoin-project/go-fil-markets/storagemarket"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/builtin/v8/miner"
"github.com/filecoin-project/go-state-types/builtin/v8/paych"
"github.com/filecoin-project/go-state-types/builtin/v9/miner"
"github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/go-state-types/dline"
abinetwork "github.com/filecoin-project/go-state-types/network"

View File

@ -26,8 +26,8 @@ import (
auth "github.com/filecoin-project/go-jsonrpc/auth"
abi "github.com/filecoin-project/go-state-types/abi"
big "github.com/filecoin-project/go-state-types/big"
miner "github.com/filecoin-project/go-state-types/builtin/v8/miner"
paych "github.com/filecoin-project/go-state-types/builtin/v8/paych"
miner "github.com/filecoin-project/go-state-types/builtin/v9/miner"
crypto "github.com/filecoin-project/go-state-types/crypto"
dline "github.com/filecoin-project/go-state-types/dline"
network "github.com/filecoin-project/go-state-types/network"

View File

@ -12,7 +12,7 @@ import (
"github.com/filecoin-project/go-fil-markets/storagemarket"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/builtin/v8/miner"
"github.com/filecoin-project/go-state-types/builtin/v9/miner"
"github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/lotus/api"

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

Binary file not shown.

View File

@ -18,6 +18,8 @@ import (
"github.com/ipld/go-car"
"golang.org/x/xerrors"
actorstypes "github.com/filecoin-project/go-state-types/actors"
"github.com/filecoin-project/lotus/blockstore"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
@ -28,14 +30,14 @@ var embeddedBuiltinActorReleases embed.FS
func init() {
if BundleOverrides == nil {
BundleOverrides = make(map[actors.Version]string)
BundleOverrides = make(map[actorstypes.Version]string)
}
for _, av := range actors.Versions {
path := os.Getenv(fmt.Sprintf("LOTUS_BUILTIN_ACTORS_V%d_BUNDLE", av))
if path == "" {
continue
}
BundleOverrides[actors.Version(av)] = path
BundleOverrides[actorstypes.Version(av)] = path
}
if err := loadManifests(NetworkBundle); err != nil {
panic(err)
@ -55,7 +57,7 @@ func UseNetworkBundle(netw string) error {
}
func loadManifests(netw string) error {
overridden := make(map[actors.Version]struct{})
overridden := make(map[actorstypes.Version]struct{})
var newMetadata []*BuiltinActorsMetadata
// First, prefer overrides.
for av, path := range BundleOverrides {
@ -94,7 +96,7 @@ func loadManifests(netw string) error {
type BuiltinActorsMetadata struct {
Network string
Version actors.Version
Version actorstypes.Version
ManifestCid cid.Cid
Actors map[string]cid.Cid
}
@ -182,7 +184,7 @@ func readEmbeddedBuiltinActorsMetadata(bundle string) ([]*BuiltinActorsMetadata,
}
bundles = append(bundles, &BuiltinActorsMetadata{
Network: name,
Version: actors.Version(version),
Version: actorstypes.Version(version),
ManifestCid: root,
Actors: actorCids,
})
@ -229,7 +231,7 @@ func readBundleManifest(r io.Reader) (cid.Cid, map[string]cid.Cid, error) {
}
// GetEmbeddedBuiltinActorsBundle returns the builtin-actors bundle for the given actors version.
func GetEmbeddedBuiltinActorsBundle(version actors.Version) ([]byte, bool) {
func GetEmbeddedBuiltinActorsBundle(version actorstypes.Version) ([]byte, bool) {
fi, err := embeddedBuiltinActorReleases.Open(fmt.Sprintf("actors/v%d.tar.zst", version))
if err != nil {
return nil, false

View File

@ -23,6 +23,23 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet
"system": MustParseCid("bafk2bzacec6xctjxybp7r3kkhase56o6jsaiua7ure5ttu2xfuojt4jhlsoa6"),
"verifiedregistry": MustParseCid("bafk2bzacec2hcqlqcfacylfcrhhliwkisvh4y3adwt47xkf2gdvodwu6ccepc"),
},
}, {
Network: "butterflynet",
Version: 9,
ManifestCid: MustParseCid("bafy2bzacebor5miojgkvov7gtiirg7hqxgm54x3hxytbho3qloqryg2r67qaq"),
Actors: map[string]cid.Cid{
"account": MustParseCid("bafk2bzacecd7kgfzbyu4sylskgf7wjqabo43y3d7xqgvz7r67pzr3ovn3sj7y"),
"cron": MustParseCid("bafk2bzacea6dc2a6skmp7saa43dcofp7zvtklvya75bai2k4k6qnkpcfzklug"),
"init": MustParseCid("bafk2bzacean5v7lbsspxmdkcwhac44sk332uwyfteibtxyhgoeabwbzbh736c"),
"multisig": MustParseCid("bafk2bzacea43lypvbof5kwnk2flzrwdrqqvzypom5xyheeuaab6dmuiafngae"),
"paymentchannel": MustParseCid("bafk2bzacecsdimcgztl4tfodnqc35jojoy4mzaqqidubialqmqaa3zpv4h3rw"),
"reward": MustParseCid("bafk2bzacedy3utj67mewe7rpieaex3sf7qxfkgiwtlgg4wlqyl74la65njbn2"),
"storagemarket": MustParseCid("bafk2bzacec4xpazf3l2p5qkknjsku2sd3skqevk7gxryumbelwhfbs7mgjnpa"),
"storageminer": MustParseCid("bafk2bzaceb5scwcdcou56vyhxq3c7vcefjau44v2h6nvsus45wqopt3hadzae"),
"storagepower": MustParseCid("bafk2bzacebxl4ssugntkckifkq6sydczcas463bmonwi2m5hddurzzcukdzyg"),
"system": MustParseCid("bafk2bzacedtw2ebtl3uccbqfcm6jd7teinlpktcglopuaxa6ev334jhs46hso"),
"verifiedregistry": MustParseCid("bafk2bzaceds62ys6rpbtjjsemohalxnkr3jtqhflifabn3xlhpi45mvi757po"),
},
}, {
Network: "calibrationnet",
Version: 8,
@ -40,6 +57,23 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet
"system": MustParseCid("bafk2bzaceaqrkllksxv2jsfgjvmuewx5vbzrammw5mdscod6gkdr3ijih2q64"),
"verifiedregistry": MustParseCid("bafk2bzaceaihibfu625lbtzdp3tcftscshrmbgghgrc7kzqhxn4455pycpdkm"),
},
}, {
Network: "calibrationnet",
Version: 9,
ManifestCid: MustParseCid("bafy2bzacectdlm3f5m252s6ken3ncnndvwj4a7hqyev2m7iba4lubkt72r2rm"),
Actors: map[string]cid.Cid{
"account": MustParseCid("bafk2bzaceag3pkyy5youg2i4qyrhqms2jobycddkhd4eebtlkeqj4wu4sw7ji"),
"cron": MustParseCid("bafk2bzaceaii7ryi4sjqqrrwyqaxulzqgiigkjqfa3f3ghhisleaqrinyal4o"),
"init": MustParseCid("bafk2bzacebpi37hcleu7cpqgs5zdg4zsw7qpydt5w25jny2dyyscsyidquvcw"),
"multisig": MustParseCid("bafk2bzacebt522zme5n3q25mecukjvomfyyzduxormgnprl73mdb5ekda2ywy"),
"paymentchannel": MustParseCid("bafk2bzacebdxmtmloxfyhxkoj4p4ze5gojqohvqjmdmv2t54xyrgfnjs52p26"),
"reward": MustParseCid("bafk2bzacebt7vup2pdxie67goc5ourij32z4ofejlrbv7styzm47ytvmmxx5a"),
"storagemarket": MustParseCid("bafk2bzacebeohybortft5jiihfvfly5oiygvf2hulnuif7vivklind32hbr3c"),
"storageminer": MustParseCid("bafk2bzaceallhekg5fhibexjurqcwrx6uzacbyq5eofic6jbdiu3vhepq6xsw"),
"storagepower": MustParseCid("bafk2bzaceassqqdljvblivbcrkv62a36gxjwf7dmkgez6ezq2oydx3dv2b3z2"),
"system": MustParseCid("bafk2bzacebxsecqifqvqxavnmsuwigmnc5rcuxoezspmykeqinkbgrkfukmgs"),
"verifiedregistry": MustParseCid("bafk2bzacedrmxfk5qifi7ujcb7mm73mwoy5e7nbndxhbqauuyol6cunf6popm"),
},
}, {
Network: "caterpillarnet",
Version: 8,
@ -57,6 +91,23 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet
"system": MustParseCid("bafk2bzacebu47th3xerlngqavlipb6cfu2utljkxxzgadc3totogto2tmx2jc"),
"verifiedregistry": MustParseCid("bafk2bzaceci3niq3rmbcmepgn27zvlgci6d5t4dvthx3pbmmx3wcu5elova6i"),
},
}, {
Network: "caterpillarnet",
Version: 9,
ManifestCid: MustParseCid("bafy2bzaceaknnblpmv3qqeqlgdycpps2vkgbgkflugbqz47k6zwrqte54hqy2"),
Actors: map[string]cid.Cid{
"account": MustParseCid("bafk2bzaceckajm6tcdpvfsrvagduv6cuefuo3modkpfupum6ibspulgvporrw"),
"cron": MustParseCid("bafk2bzacea74zhlldpihms2ohp3wvefojifvudbblmeju3izwrpcpxemp43fo"),
"init": MustParseCid("bafk2bzacea5nqh4l76vm4ys6vgrqyt77tquk66il3w5ho3zxugka22fipdkdw"),
"multisig": MustParseCid("bafk2bzacea3ftmx2roav4psh63r5n2sol6x3kwpmfwe473pexhj6lg7pruu2k"),
"paymentchannel": MustParseCid("bafk2bzacea2gqhnycejjfuinywoz4j7pmsvxn3i2y5epdx5vqpo23phx6jeac"),
"reward": MustParseCid("bafk2bzaceamdxogvus7zawqtju3vesmj6ffpf3ta6dlwvvstyfbf23sow2tes"),
"storagemarket": MustParseCid("bafk2bzacecvh6qhfe3ityehpibxmmw43l7recwtru3l4n3yrdj5bmnv4efnrc"),
"storageminer": MustParseCid("bafk2bzaced6ya5wlvplkvnvmhuc2uh5zq7oft6pyyoouwouuoreuk6grn6vsw"),
"storagepower": MustParseCid("bafk2bzacedbfoblr65vbqwx37cym6v3zhbgrau46vma4c2lbh6toz6q5dyrtc"),
"system": MustParseCid("bafk2bzaced7z2lu5hp4qpsesbmubq3chrad3sl6kgveldafksh4w252ijjaw2"),
"verifiedregistry": MustParseCid("bafk2bzacec6fdlcvlnaiktdptogae3bgofhzo24lhn4hs6rsa2zbnknfpsct6"),
},
}, {
Network: "devnet",
Version: 8,
@ -74,6 +125,23 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet
"system": MustParseCid("bafk2bzacecf7eta2stfd3cnuxzervd33imbvlaqq6b5tsho7pxmhifrybreru"),
"verifiedregistry": MustParseCid("bafk2bzaceaajgtglewgitshgdi2nzrvq7eihjtyqj5yiamesqun2hujl3xev2"),
},
}, {
Network: "devnet",
Version: 9,
ManifestCid: MustParseCid("bafy2bzacecogd7hb3dap7d4abyikdgt6b2zs46s4qyilsgxk4rsienbvvstp4"),
Actors: map[string]cid.Cid{
"account": MustParseCid("bafk2bzacecrgqcwn2j6c44tnfx32om4upg56b7gdwslfgeuyfsm6iwkiuhm2w"),
"cron": MustParseCid("bafk2bzaceblepwha5i5cpac37arpcxjcebm5k7p4e5ed7bwcq7ie6fryxgno4"),
"init": MustParseCid("bafk2bzacebjr3xwsdzfie47rtffibt3irr7a5qqstt7fsbwnolzz3z6oy5frw"),
"multisig": MustParseCid("bafk2bzacec66uf5u7o7q3u3pufrtufya6ntwrreysrwwlzqdjbtj36ajuamz4"),
"paymentchannel": MustParseCid("bafk2bzacebouukxeahifxfoymmvibngg6abftd7luiq5x2c7zxulvqyerwoeg"),
"reward": MustParseCid("bafk2bzacecj4pry2xb6w4kd4xxvs3dqd2endfynnwrkf66zakmt376tafy6ym"),
"storagemarket": MustParseCid("bafk2bzacecmij6fgaasgu7zm354fltmvhwmepzwadhl4euxhb64yg4pgfkxgw"),
"storageminer": MustParseCid("bafk2bzaceb5qyhchlvqvcq5cvrc5tuyjrrz6qkgbbxx4vr4wxhtoa4bfp56bg"),
"storagepower": MustParseCid("bafk2bzaced377v52henedhmudi2isuxe73mp2lrv2zyyxfp4r4uppz3sy2ipw"),
"system": MustParseCid("bafk2bzacebb3gdmg2fqexijivo7dkxj6g6gu7ou2jsw6opszr5gfmwt4fvorw"),
"verifiedregistry": MustParseCid("bafk2bzacec5xfb3a56mlclymhvs2br3qzx7sagqda4dvl4xz3fgiymkkbz5tk"),
},
}, {
Network: "mainnet",
Version: 8,
@ -91,6 +159,23 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet
"system": MustParseCid("bafk2bzacedwq5uppsw7vp55zpj7jdieizirmldceehu6wvombw3ixq2tcq57w"),
"verifiedregistry": MustParseCid("bafk2bzaceb3zbkjz3auizmoln2unmxep7dyfcmsre64vnqfhdyh7rkqfoxlw4"),
},
}, {
Network: "mainnet",
Version: 9,
ManifestCid: MustParseCid("bafy2bzaceb7nrn4icde3yt7s2kpllliodblq2i3iuslh3l6swgjqyusual72u"),
Actors: map[string]cid.Cid{
"account": MustParseCid("bafk2bzacedchhykcbvptlrnts62xa2h7fewsyvb4imktudll7tbogkwj4ccpy"),
"cron": MustParseCid("bafk2bzaced2e2ivtglevf5tnqay6eqdl3m5ilx4az766ojbhmy2kbxmkogbni"),
"init": MustParseCid("bafk2bzaceapzqn6e3cfpf4ntln4dkyrqe5egygmjczefduy7fuabxh2npqq6o"),
"multisig": MustParseCid("bafk2bzacebxihi4x4lzelmmdtxiz5gub3cjgthrgxuj5mxl2ihxaz6qhp5qbu"),
"paymentchannel": MustParseCid("bafk2bzacecv34ahs6k552won2vj4r62gur5i7inqnycg7y4dg27ktlq76stlk"),
"reward": MustParseCid("bafk2bzacea4er76nlnzz3muuvdxs4dbygejztezanpafi42idj57n75sumu7o"),
"storagemarket": MustParseCid("bafk2bzacedd3pjxcwgxfli4a5udw3ebbo4gom43epizbldvto7ovduqk6udj6"),
"storageminer": MustParseCid("bafk2bzacebtuopxp2464fxulzfyr4iw7bj4pelfxlatudaf6q5qtahokeo3lo"),
"storagepower": MustParseCid("bafk2bzacec3dmcwtizgy6qhxg6fgb4ykc2pamxxh2n5oyeqvebjf3ikzd2sui"),
"system": MustParseCid("bafk2bzacecrm36gf2gusruvhfc6ukf36qflsr5pdbquvfyysprdyudsatoufm"),
"verifiedregistry": MustParseCid("bafk2bzaceah3mwu6tb4jmffohpoz6nyoxpgno2hmxz455rycw4o2hrat3yg3u"),
},
}, {
Network: "testing",
Version: 8,
@ -108,6 +193,23 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet
"system": MustParseCid("bafk2bzaced6kjkbv7lrb2qwq5we2hqaxc6ztch5p52g27qtjy45zdemsk4b7m"),
"verifiedregistry": MustParseCid("bafk2bzacectzxvtoselhnzsair5nv6k5vokvegnht6z2lfee4p3xexo4kg4m6"),
},
}, {
Network: "testing",
Version: 9,
ManifestCid: MustParseCid("bafy2bzaceas5fka4rtyvnqwvvwdi2qqhbnu7hnyz37chhpflh4rdbwnoupols"),
Actors: map[string]cid.Cid{
"account": MustParseCid("bafk2bzacecsmbmd42fsg33wd3u5vxyp4n4a4mac423fduauishjhiyv2bqz7w"),
"cron": MustParseCid("bafk2bzacedajlwnkefucjxzasudkfojrz3bnhnnirebvacxrtly5y2kfb7qiu"),
"init": MustParseCid("bafk2bzaceat7cvf7s2vnmqoldzafkpjygi6wv3sfnclenfbahk4htsgu4aqsa"),
"multisig": MustParseCid("bafk2bzacebh7pwb7eoyigwgjs2r32ebtxwbwgxqd4cvou4katq4axmhd7lxsq"),
"paymentchannel": MustParseCid("bafk2bzaceb6nbmyo2girdpnwywby7yzelx7g6s4snbq3kb3mmd2pp33qefkww"),
"reward": MustParseCid("bafk2bzacedttgmuddtlrp2ie4i2vzuueury455knof5muqtqlslscxrk7ucl6"),
"storagemarket": MustParseCid("bafk2bzacebjtz7fg5n2sm4wg464fyg5vcvux5hqrsdwki675hsquhh3rpe5rg"),
"storageminer": MustParseCid("bafk2bzacea2c2genvtsktr3f6yjlny57gwqyt5dbqrfws56wn5ssyl2tevjjg"),
"storagepower": MustParseCid("bafk2bzaceasmr5xc3c7jgihqcb5pdv557kfor72wlmzmh4syvedknelebhsve"),
"system": MustParseCid("bafk2bzaceabj3whuno364pjqn7sphwquiqpl2w5le6aa6quwytgyxshvelcwq"),
"verifiedregistry": MustParseCid("bafk2bzaceamn6gzihkytyqym4dqs7wqmo2fz6kpge4tphumvutsp2ys4bwaha"),
},
}, {
Network: "testing-fake-proofs",
Version: 8,
@ -125,4 +227,21 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet
"system": MustParseCid("bafk2bzaced6kjkbv7lrb2qwq5we2hqaxc6ztch5p52g27qtjy45zdemsk4b7m"),
"verifiedregistry": MustParseCid("bafk2bzacectzxvtoselhnzsair5nv6k5vokvegnht6z2lfee4p3xexo4kg4m6"),
},
}, {
Network: "testing-fake-proofs",
Version: 9,
ManifestCid: MustParseCid("bafy2bzacebr7bo4shotwq4cct3ablt6hlcozg4h2e52av2q3md5di7sibrqj2"),
Actors: map[string]cid.Cid{
"account": MustParseCid("bafk2bzacecsmbmd42fsg33wd3u5vxyp4n4a4mac423fduauishjhiyv2bqz7w"),
"cron": MustParseCid("bafk2bzacedajlwnkefucjxzasudkfojrz3bnhnnirebvacxrtly5y2kfb7qiu"),
"init": MustParseCid("bafk2bzaceat7cvf7s2vnmqoldzafkpjygi6wv3sfnclenfbahk4htsgu4aqsa"),
"multisig": MustParseCid("bafk2bzacebh7pwb7eoyigwgjs2r32ebtxwbwgxqd4cvou4katq4axmhd7lxsq"),
"paymentchannel": MustParseCid("bafk2bzaceb6nbmyo2girdpnwywby7yzelx7g6s4snbq3kb3mmd2pp33qefkww"),
"reward": MustParseCid("bafk2bzacedttgmuddtlrp2ie4i2vzuueury455knof5muqtqlslscxrk7ucl6"),
"storagemarket": MustParseCid("bafk2bzacebjtz7fg5n2sm4wg464fyg5vcvux5hqrsdwki675hsquhh3rpe5rg"),
"storageminer": MustParseCid("bafk2bzacedaxvye4reegpy2fecjuzwt4nly2myhplnvkzhssquo2jjw7vfmuy"),
"storagepower": MustParseCid("bafk2bzaceaoteuuvld3bzy3t3kzjp5iabgkvxjc5cxq2ziwankpxqqixkqqjw"),
"system": MustParseCid("bafk2bzaceabj3whuno364pjqn7sphwquiqpl2w5le6aa6quwytgyxshvelcwq"),
"verifiedregistry": MustParseCid("bafk2bzaceamn6gzihkytyqym4dqs7wqmo2fz6kpge4tphumvutsp2ys4bwaha"),
},
}}

View File

@ -5,6 +5,8 @@ import (
"github.com/stretchr/testify/require"
actorstypes "github.com/filecoin-project/go-state-types/actors"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors"
)
@ -19,16 +21,16 @@ func TestEmbeddedMetadata(t *testing.T) {
// Test that we're registering the manifest correctly.
func TestRegistration(t *testing.T) {
manifestCid, found := actors.GetManifest(actors.Version8)
manifestCid, found := actors.GetManifest(actorstypes.Version8)
require.True(t, found)
require.True(t, manifestCid.Defined())
for _, key := range actors.GetBuiltinActorsKeys() {
actorCid, found := actors.GetActorCodeID(actors.Version8, key)
actorCid, found := actors.GetActorCodeID(actorstypes.Version8, key)
require.True(t, found)
name, version, found := actors.GetActorMetaByCode(actorCid)
require.True(t, found)
require.Equal(t, actors.Version8, version)
require.Equal(t, actorstypes.Version8, version)
require.Equal(t, key, name)
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -10,9 +10,9 @@ import (
"github.com/ipfs/go-cid"
"github.com/filecoin-project/go-state-types/abi"
actorstypes "github.com/filecoin-project/go-state-types/actors"
"github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/policy"
)
@ -20,7 +20,7 @@ const BootstrappersFile = ""
const GenesisFile = ""
var NetworkBundle = "devnet"
var BundleOverrides map[actors.Version]string
var BundleOverrides map[actorstypes.Version]string
const GenesisNetworkVersion = network.Version16
@ -56,6 +56,8 @@ var UpgradeOhSnapHeight = abi.ChainEpoch(-18)
var UpgradeSkyrHeight = abi.ChainEpoch(-19)
var UpgradeV17Height = abi.ChainEpoch(99999999999999)
var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,
}
@ -107,6 +109,7 @@ func init() {
UpgradeChocolateHeight = getUpgradeHeight("LOTUS_CHOCOLATE_HEIGHT", UpgradeChocolateHeight)
UpgradeOhSnapHeight = getUpgradeHeight("LOTUS_OHSNAP_HEIGHT", UpgradeOhSnapHeight)
UpgradeSkyrHeight = getUpgradeHeight("LOTUS_SKYR_HEIGHT", UpgradeSkyrHeight)
UpgradeV17Height = getUpgradeHeight("LOTUS_V17_HEIGHT", UpgradeV17Height)
BuildType |= Build2k

View File

@ -8,10 +8,10 @@ import (
"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/network"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/policy"
)
@ -19,10 +19,10 @@ var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,
}
const GenesisNetworkVersion = network.Version15
const GenesisNetworkVersion = network.Version16
var NetworkBundle = "butterflynet"
var BundleOverrides map[actors.Version]string
var BundleOverrides map[actorstypes.Version]string
const BootstrappersFile = "butterflynet.pi"
const GenesisFile = "butterflynet.car"
@ -47,10 +47,9 @@ const UpgradeNorwegianHeight = -14
const UpgradeTurboHeight = -15
const UpgradeHyperdriveHeight = -16
const UpgradeChocolateHeight = -17
const UpgradeOhSnapHeight = -18
const UpgradeSkyrHeight = abi.ChainEpoch(50)
const UpgradeSkyrHeight = -19
const UpgradeV17Height = abi.ChainEpoch(99999999999999)
var SupportedProofTypes = []abi.RegisteredSealProof{
abi.RegisteredSealProof_StackedDrg512MiBV1,

View File

@ -8,10 +8,10 @@ import (
"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/network"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/policy"
)
@ -22,7 +22,7 @@ var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
const GenesisNetworkVersion = network.Version0
var NetworkBundle = "calibrationnet"
var BundleOverrides map[actors.Version]string
var BundleOverrides map[actorstypes.Version]string
const BootstrappersFile = "calibnet.pi"
const GenesisFile = "calibnet.car"
@ -66,6 +66,8 @@ const UpgradeOhSnapHeight = 682006
// 2022-06-16T17:30:00Z
const UpgradeSkyrHeight = 1044660
var UpgradeV17Height = abi.ChainEpoch(99999999999999)
var SupportedProofTypes = []abi.RegisteredSealProof{
abi.RegisteredSealProof_StackedDrg32GiBV1,
abi.RegisteredSealProof_StackedDrg64GiBV1,

View File

@ -11,20 +11,20 @@ import (
"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/network"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/policy"
)
var NetworkBundle = "caterpillarnet"
var BundleOverrides map[actors.Version]string
var BundleOverrides map[actorstypes.Version]string
const BootstrappersFile = "interopnet.pi"
const GenesisFile = "interopnet.car"
const GenesisNetworkVersion = network.Version15
const GenesisNetworkVersion = network.Version16
var UpgradeBreezeHeight = abi.ChainEpoch(-1)
@ -34,26 +34,22 @@ var UpgradeSmokeHeight = abi.ChainEpoch(-1)
var UpgradeIgnitionHeight = abi.ChainEpoch(-2)
var UpgradeRefuelHeight = abi.ChainEpoch(-3)
var UpgradeTapeHeight = abi.ChainEpoch(-4)
var UpgradeAssemblyHeight = abi.ChainEpoch(-5)
var UpgradeLiftoffHeight = abi.ChainEpoch(-6)
var UpgradeKumquatHeight = abi.ChainEpoch(-7)
var UpgradeCalicoHeight = abi.ChainEpoch(-9)
var UpgradePersianHeight = abi.ChainEpoch(-10)
var UpgradeOrangeHeight = abi.ChainEpoch(-11)
var UpgradeClausHeight = abi.ChainEpoch(-12)
var UpgradeTrustHeight = abi.ChainEpoch(-13)
var UpgradeNorwegianHeight = abi.ChainEpoch(-14)
var UpgradeTurboHeight = abi.ChainEpoch(-15)
var UpgradeHyperdriveHeight = abi.ChainEpoch(-16)
var UpgradeChocolateHeight = abi.ChainEpoch(-17)
var UpgradeOhSnapHeight = abi.ChainEpoch(-18)
var UpgradeSkyrHeight = abi.ChainEpoch(100)
var UpgradeSkyrHeight = abi.ChainEpoch(-19)
const UpgradeV17Height = abi.ChainEpoch(99999999999999)
var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,
@ -107,6 +103,7 @@ func init() {
UpgradeChocolateHeight = getUpgradeHeight("LOTUS_CHOCOLATE_HEIGHT", UpgradeChocolateHeight)
UpgradeOhSnapHeight = getUpgradeHeight("LOTUS_OHSNAP_HEIGHT", UpgradeOhSnapHeight)
UpgradeSkyrHeight = getUpgradeHeight("LOTUS_SKYR_HEIGHT", UpgradeSkyrHeight)
UpgradeV17Height = getUpgradeHeight("LOTUS_V17_HEIGHT", UpgradeV17Height)
BuildType |= BuildInteropnet
SetAddressNetwork(address.Testnet)

View File

@ -9,10 +9,9 @@ import (
"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/network"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors"
)
var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
@ -23,7 +22,7 @@ var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
var NetworkBundle = "mainnet"
// NOTE: DO NOT change this unless you REALLY know what you're doing. This is consensus critical.
var BundleOverrides map[actors.Version]string
var BundleOverrides map[actorstypes.Version]string
const GenesisNetworkVersion = network.Version0
@ -77,7 +76,9 @@ const UpgradeChocolateHeight = 1231620
const UpgradeOhSnapHeight = 1594680
// 2022-07-06T14:00:00Z
var UpgradeSkyrHeight = abi.ChainEpoch(1960320)
const UpgradeSkyrHeight = 1960320
var UpgradeV17Height = abi.ChainEpoch(99999999999999)
var SupportedProofTypes = []abi.RegisteredSealProof{
abi.RegisteredSealProof_StackedDrg32GiBV1,
@ -92,8 +93,8 @@ func init() {
SetAddressNetwork(address.Mainnet)
}
if os.Getenv("LOTUS_DISABLE_SKYR") == "1" {
UpgradeSkyrHeight = math.MaxInt64
if os.Getenv("LOTUS_DISABLE_V17") == "1" {
UpgradeV17Height = math.MaxInt64
}
Devnet = false

View File

@ -33,7 +33,7 @@ const NewestNetworkVersion = network.Version{{.latestNetworkVersion}}
/* inline-gen start */
const NewestNetworkVersion = network.Version16
const NewestNetworkVersion = network.Version17
/* inline-gen end */

View File

@ -13,10 +13,10 @@ import (
"github.com/ipfs/go-cid"
"github.com/filecoin-project/go-state-types/abi"
actorstypes "github.com/filecoin-project/go-state-types/actors"
"github.com/filecoin-project/go-state-types/network"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/policy"
)
@ -107,6 +107,7 @@ var (
UpgradeChocolateHeight abi.ChainEpoch = -16
UpgradeOhSnapHeight abi.ChainEpoch = -17
UpgradeSkyrHeight abi.ChainEpoch = -18
UpgradeV17Height abi.ChainEpoch = -19
DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,
@ -114,10 +115,10 @@ var (
GenesisNetworkVersion = network.Version0
NetworkBundle = "devnet"
BundleOverrides map[actors.Version]string
BundleOverrides map[actorstypes.Version]string
NewestNetworkVersion = network.Version15
ActorUpgradeNetworkVersion = network.Version15
NewestNetworkVersion = network.Version16
ActorUpgradeNetworkVersion = network.Version16
Devnet = true
ZeroAddress = MustParseAddress("f3yaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaby2smx7a")

View File

@ -4,6 +4,7 @@ import (
"github.com/ipfs/go-cid"
"golang.org/x/xerrors"
actorstypes "github.com/filecoin-project/go-state-types/actors"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"
@ -14,10 +15,10 @@ import (
)
// GetActorCodeID looks up a builtin actor's code CID by actor version and canonical actor name.
func GetActorCodeID(av Version, name string) (cid.Cid, bool) {
func GetActorCodeID(av actorstypes.Version, name string) (cid.Cid, bool) {
// Actors V8 and above
if av >= Version8 {
if av >= actorstypes.Version8 {
if cids, ok := GetActorCodeIDsFromManifest(av); ok {
c, ok := cids[name]
return c, ok
@ -30,275 +31,275 @@ func GetActorCodeID(av Version, name string) (cid.Cid, bool) {
case AccountKey:
switch av {
case Version0:
case actorstypes.Version0:
return builtin0.AccountActorCodeID, true
case Version2:
case actorstypes.Version2:
return builtin2.AccountActorCodeID, true
case Version3:
case actorstypes.Version3:
return builtin3.AccountActorCodeID, true
case Version4:
case actorstypes.Version4:
return builtin4.AccountActorCodeID, true
case Version5:
case actorstypes.Version5:
return builtin5.AccountActorCodeID, true
case Version6:
case actorstypes.Version6:
return builtin6.AccountActorCodeID, true
case Version7:
case actorstypes.Version7:
return builtin7.AccountActorCodeID, true
}
case CronKey:
switch av {
case Version0:
case actorstypes.Version0:
return builtin0.CronActorCodeID, true
case Version2:
case actorstypes.Version2:
return builtin2.CronActorCodeID, true
case Version3:
case actorstypes.Version3:
return builtin3.CronActorCodeID, true
case Version4:
case actorstypes.Version4:
return builtin4.CronActorCodeID, true
case Version5:
case actorstypes.Version5:
return builtin5.CronActorCodeID, true
case Version6:
case actorstypes.Version6:
return builtin6.CronActorCodeID, true
case Version7:
case actorstypes.Version7:
return builtin7.CronActorCodeID, true
}
case InitKey:
switch av {
case Version0:
case actorstypes.Version0:
return builtin0.InitActorCodeID, true
case Version2:
case actorstypes.Version2:
return builtin2.InitActorCodeID, true
case Version3:
case actorstypes.Version3:
return builtin3.InitActorCodeID, true
case Version4:
case actorstypes.Version4:
return builtin4.InitActorCodeID, true
case Version5:
case actorstypes.Version5:
return builtin5.InitActorCodeID, true
case Version6:
case actorstypes.Version6:
return builtin6.InitActorCodeID, true
case Version7:
case actorstypes.Version7:
return builtin7.InitActorCodeID, true
}
case MarketKey:
switch av {
case Version0:
case actorstypes.Version0:
return builtin0.StorageMarketActorCodeID, true
case Version2:
case actorstypes.Version2:
return builtin2.StorageMarketActorCodeID, true
case Version3:
case actorstypes.Version3:
return builtin3.StorageMarketActorCodeID, true
case Version4:
case actorstypes.Version4:
return builtin4.StorageMarketActorCodeID, true
case Version5:
case actorstypes.Version5:
return builtin5.StorageMarketActorCodeID, true
case Version6:
case actorstypes.Version6:
return builtin6.StorageMarketActorCodeID, true
case Version7:
case actorstypes.Version7:
return builtin7.StorageMarketActorCodeID, true
}
case MinerKey:
switch av {
case Version0:
case actorstypes.Version0:
return builtin0.StorageMinerActorCodeID, true
case Version2:
case actorstypes.Version2:
return builtin2.StorageMinerActorCodeID, true
case Version3:
case actorstypes.Version3:
return builtin3.StorageMinerActorCodeID, true
case Version4:
case actorstypes.Version4:
return builtin4.StorageMinerActorCodeID, true
case Version5:
case actorstypes.Version5:
return builtin5.StorageMinerActorCodeID, true
case Version6:
case actorstypes.Version6:
return builtin6.StorageMinerActorCodeID, true
case Version7:
case actorstypes.Version7:
return builtin7.StorageMinerActorCodeID, true
}
case MultisigKey:
switch av {
case Version0:
case actorstypes.Version0:
return builtin0.MultisigActorCodeID, true
case Version2:
case actorstypes.Version2:
return builtin2.MultisigActorCodeID, true
case Version3:
case actorstypes.Version3:
return builtin3.MultisigActorCodeID, true
case Version4:
case actorstypes.Version4:
return builtin4.MultisigActorCodeID, true
case Version5:
case actorstypes.Version5:
return builtin5.MultisigActorCodeID, true
case Version6:
case actorstypes.Version6:
return builtin6.MultisigActorCodeID, true
case Version7:
case actorstypes.Version7:
return builtin7.MultisigActorCodeID, true
}
case PaychKey:
switch av {
case Version0:
case actorstypes.Version0:
return builtin0.PaymentChannelActorCodeID, true
case Version2:
case actorstypes.Version2:
return builtin2.PaymentChannelActorCodeID, true
case Version3:
case actorstypes.Version3:
return builtin3.PaymentChannelActorCodeID, true
case Version4:
case actorstypes.Version4:
return builtin4.PaymentChannelActorCodeID, true
case Version5:
case actorstypes.Version5:
return builtin5.PaymentChannelActorCodeID, true
case Version6:
case actorstypes.Version6:
return builtin6.PaymentChannelActorCodeID, true
case Version7:
case actorstypes.Version7:
return builtin7.PaymentChannelActorCodeID, true
}
case PowerKey:
switch av {
case Version0:
case actorstypes.Version0:
return builtin0.StoragePowerActorCodeID, true
case Version2:
case actorstypes.Version2:
return builtin2.StoragePowerActorCodeID, true
case Version3:
case actorstypes.Version3:
return builtin3.StoragePowerActorCodeID, true
case Version4:
case actorstypes.Version4:
return builtin4.StoragePowerActorCodeID, true
case Version5:
case actorstypes.Version5:
return builtin5.StoragePowerActorCodeID, true
case Version6:
case actorstypes.Version6:
return builtin6.StoragePowerActorCodeID, true
case Version7:
case actorstypes.Version7:
return builtin7.StoragePowerActorCodeID, true
}
case RewardKey:
switch av {
case Version0:
case actorstypes.Version0:
return builtin0.RewardActorCodeID, true
case Version2:
case actorstypes.Version2:
return builtin2.RewardActorCodeID, true
case Version3:
case actorstypes.Version3:
return builtin3.RewardActorCodeID, true
case Version4:
case actorstypes.Version4:
return builtin4.RewardActorCodeID, true
case Version5:
case actorstypes.Version5:
return builtin5.RewardActorCodeID, true
case Version6:
case actorstypes.Version6:
return builtin6.RewardActorCodeID, true
case Version7:
case actorstypes.Version7:
return builtin7.RewardActorCodeID, true
}
case SystemKey:
switch av {
case Version0:
case actorstypes.Version0:
return builtin0.SystemActorCodeID, true
case Version2:
case actorstypes.Version2:
return builtin2.SystemActorCodeID, true
case Version3:
case actorstypes.Version3:
return builtin3.SystemActorCodeID, true
case Version4:
case actorstypes.Version4:
return builtin4.SystemActorCodeID, true
case Version5:
case actorstypes.Version5:
return builtin5.SystemActorCodeID, true
case Version6:
case actorstypes.Version6:
return builtin6.SystemActorCodeID, true
case Version7:
case actorstypes.Version7:
return builtin7.SystemActorCodeID, true
}
case VerifregKey:
switch av {
case Version0:
case actorstypes.Version0:
return builtin0.VerifiedRegistryActorCodeID, true
case Version2:
case actorstypes.Version2:
return builtin2.VerifiedRegistryActorCodeID, true
case Version3:
case actorstypes.Version3:
return builtin3.VerifiedRegistryActorCodeID, true
case Version4:
case actorstypes.Version4:
return builtin4.VerifiedRegistryActorCodeID, true
case Version5:
case actorstypes.Version5:
return builtin5.VerifiedRegistryActorCodeID, true
case Version6:
case actorstypes.Version6:
return builtin6.VerifiedRegistryActorCodeID, true
case Version7:
case actorstypes.Version7:
return builtin7.VerifiedRegistryActorCodeID, true
}
}
@ -307,7 +308,7 @@ func GetActorCodeID(av Version, name string) (cid.Cid, bool) {
}
// GetActorCodeIDs looks up all builtin actor's code CIDs by actor version.
func GetActorCodeIDs(av Version) (map[string]cid.Cid, error) {
func GetActorCodeIDs(av actorstypes.Version) (map[string]cid.Cid, error) {
cids, ok := GetActorCodeIDsFromManifest(av)
if ok {
return cids, nil

View File

@ -44,6 +44,11 @@ func main() {
fmt.Println(err)
return
}
if err := generateRegistry("chain/actors/builtin/registry.go"); err != nil {
fmt.Println(err)
return
}
}
func generateAdapters() error {
@ -110,6 +115,7 @@ func generateState(actDir string) error {
err := tpl.Execute(&b, map[string]interface{}{
"v": version,
"import": getVersionImports()[version],
"latestVersion": lotusactors.LatestVersion,
})
if err != nil {
return err
@ -141,6 +147,7 @@ func generateMessages(actDir string) error {
err := tpl.Execute(&b, map[string]interface{}{
"v": version,
"import": getVersionImports()[version],
"latestVersion": lotusactors.LatestVersion,
})
if err != nil {
return err
@ -216,6 +223,36 @@ func generateBuiltin(builtinPath string) error {
return nil
}
func generateRegistry(registryPath string) error {
bf, err := ioutil.ReadFile(registryPath + ".template")
if err != nil {
if os.IsNotExist(err) {
return nil // skip
}
return xerrors.Errorf("loading registry template file: %w", err)
}
tpl := template.Must(template.New("").Funcs(template.FuncMap{
"import": func(v int) string { return getVersionImports()[v] },
}).Parse(string(bf)))
var b bytes.Buffer
err = tpl.Execute(&b, map[string]interface{}{
"versions": lotusactors.Versions,
})
if err != nil {
return err
}
if err := ioutil.WriteFile(registryPath, b.Bytes(), 0666); err != nil {
return err
}
return nil
}
func getVersionImports() map[int]string {
versionImports := make(map[int]string, lotusactors.LatestVersion)
for _, v := range lotusactors.Versions {

View File

@ -4,7 +4,8 @@ import (
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
builtin8 "github.com/filecoin-project/go-state-types/builtin"
actorstypes "github.com/filecoin-project/go-state-types/actors"
builtin9 "github.com/filecoin-project/go-state-types/builtin"
"github.com/filecoin-project/go-state-types/cbor"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
@ -19,7 +20,7 @@ import (
"github.com/filecoin-project/lotus/chain/types"
)
var Methods = builtin8.MethodsAccount
var Methods = builtin9.MethodsAccount
func Load(store adt.Store, act *types.Actor) (State, error) {
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
@ -29,9 +30,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
switch av {
case actors.Version8:
case actorstypes.Version8:
return load8(store, act.Head)
case actorstypes.Version9:
return load9(store, act.Head)
}
}
@ -63,33 +67,36 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version, addr address.Address) (State, error) {
func MakeState(store adt.Store, av actorstypes.Version, addr address.Address) (State, error) {
switch av {
case actors.Version0:
case actorstypes.Version0:
return make0(store, addr)
case actors.Version2:
case actorstypes.Version2:
return make2(store, addr)
case actors.Version3:
case actorstypes.Version3:
return make3(store, addr)
case actors.Version4:
case actorstypes.Version4:
return make4(store, addr)
case actors.Version5:
case actorstypes.Version5:
return make5(store, addr)
case actors.Version6:
case actorstypes.Version6:
return make6(store, addr)
case actors.Version7:
case actorstypes.Version7:
return make7(store, addr)
case actors.Version8:
case actorstypes.Version8:
return make8(store, addr)
case actorstypes.Version9:
return make9(store, addr)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}

View File

@ -1,6 +1,7 @@
package account
import (
actorstypes "github.com/filecoin-project/go-state-types/actors"
"github.com/filecoin-project/lotus/chain/actors"
"golang.org/x/xerrors"
@ -9,13 +10,13 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/types"
{{range .versions}}
{{if (le . 7)}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
{{else}}
builtin{{.}} "github.com/filecoin-project/go-state-types/builtin"
{{end}}
{{end}}
builtin{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin"
)
var Methods = builtin{{.latestVersion}}.MethodsAccount
@ -29,7 +30,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
switch av {
{{range .versions}}
{{if (ge . 8)}}
case actors.Version{{.}}:
case actorstypes.Version{{.}}:
return load{{.}}(store, act.Head)
{{end}}
{{end}}
@ -48,10 +49,10 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version, addr address.Address) (State, error) {
func MakeState(store adt.Store, av actorstypes.Version, addr address.Address) (State, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
case actorstypes.Version{{.}}:
return make{{.}}(store, addr)
{{end}}
}

View File

@ -0,0 +1,40 @@
package account
import (
"github.com/ipfs/go-cid"
"github.com/filecoin-project/go-address"
account9 "github.com/filecoin-project/go-state-types/builtin/v9/account"
"github.com/filecoin-project/lotus/chain/actors/adt"
)
var _ State = (*state9)(nil)
func load9(store adt.Store, root cid.Cid) (State, error) {
out := state9{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make9(store adt.Store, addr address.Address) (State, error) {
out := state9{store: store}
out.State = account9.State{Address: addr}
return &out, nil
}
type state9 struct {
account9.State
store adt.Store
}
func (s *state9) PubkeyAddress() (address.Address, error) {
return s.Address, nil
}
func (s *state9) GetState() interface{} {
return &s.State
}

View File

@ -8,8 +8,8 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/builtin"
miner8 "github.com/filecoin-project/go-state-types/builtin/v8/miner"
smoothingtypes "github.com/filecoin-project/go-state-types/builtin/v8/util/smoothing"
minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner"
"github.com/filecoin-project/go-state-types/proof"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
@ -18,7 +18,6 @@ import (
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors"
)
@ -53,7 +52,7 @@ type PoStProof = proof.PoStProof
type FilterEstimate = smoothingtypes.FilterEstimate
func QAPowerForWeight(size abi.SectorSize, duration abi.ChainEpoch, dealWeight, verifiedWeight abi.DealWeight) abi.StoragePower {
return miner8.QAPowerForWeight(size, duration, dealWeight, verifiedWeight)
return minertypes.QAPowerForWeight(size, duration, dealWeight, verifiedWeight)
}
func ActorNameByCode(c cid.Cid) string {
@ -84,9 +83,6 @@ func ActorNameByCode(c cid.Cid) string {
case builtin7.IsBuiltinActor(c):
return builtin7.ActorNameByCode(c)
case builtin8.IsBuiltinActor(c):
return builtin8.ActorNameByCode(c)
default:
return "<unknown>"
}

View File

@ -7,8 +7,10 @@ import (
"github.com/ipfs/go-cid"
{{range .versions}}
{{if (le . 7)}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
{{end}}
{{end}}
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/proof"
@ -16,7 +18,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors"
miner{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin/v8/miner"
minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner"
smoothingtypes "github.com/filecoin-project/go-state-types/builtin/v8/util/smoothing"
)
@ -50,7 +52,7 @@ type PoStProof = proof.PoStProof
type FilterEstimate = smoothingtypes.FilterEstimate
func QAPowerForWeight(size abi.SectorSize, duration abi.ChainEpoch, dealWeight, verifiedWeight abi.DealWeight) abi.StoragePower {
return miner{{.latestVersion}}.QAPowerForWeight(size, duration, dealWeight, verifiedWeight)
return minertypes.QAPowerForWeight(size, duration, dealWeight, verifiedWeight)
}
func ActorNameByCode(c cid.Cid) string {
@ -60,9 +62,11 @@ func ActorNameByCode(c cid.Cid) string {
switch {
{{range .versions}}
{{if (le . 7)}}
case builtin{{.}}.IsBuiltinActor(c):
return builtin{{.}}.ActorNameByCode(c)
{{end}}
{{end}}
default:
return "<unknown>"
}

View File

@ -1,6 +1,7 @@
package cron
import (
actorstypes "github.com/filecoin-project/go-state-types/actors"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"golang.org/x/xerrors"
@ -9,10 +10,9 @@ import (
{{range .versions}}
{{if (le . 7)}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
{{else}}
builtin{{.}} "github.com/filecoin-project/go-state-types/builtin"
{{end}}
{{end}}
builtin{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin"
)
func Load(store adt.Store, act *types.Actor) (State, error) {
@ -24,7 +24,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
switch av {
{{range .versions}}
{{if (ge . 8)}}
case actors.Version{{.}}:
case actorstypes.Version{{.}}:
return load{{.}}(store, act.Head)
{{end}}
{{end}}
@ -43,10 +43,10 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version) (State, error) {
func MakeState(store adt.Store, av actorstypes.Version) (State, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
case actorstypes.Version{{.}}:
return make{{.}}(store)
{{end}}
}

View File

@ -3,7 +3,8 @@ package cron
import (
"golang.org/x/xerrors"
builtin8 "github.com/filecoin-project/go-state-types/builtin"
actorstypes "github.com/filecoin-project/go-state-types/actors"
builtin9 "github.com/filecoin-project/go-state-types/builtin"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"
@ -25,9 +26,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
switch av {
case actors.Version8:
case actorstypes.Version8:
return load8(store, act.Head)
case actorstypes.Version9:
return load9(store, act.Head)
}
}
@ -59,40 +63,43 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version) (State, error) {
func MakeState(store adt.Store, av actorstypes.Version) (State, error) {
switch av {
case actors.Version0:
case actorstypes.Version0:
return make0(store)
case actors.Version2:
case actorstypes.Version2:
return make2(store)
case actors.Version3:
case actorstypes.Version3:
return make3(store)
case actors.Version4:
case actorstypes.Version4:
return make4(store)
case actors.Version5:
case actorstypes.Version5:
return make5(store)
case actors.Version6:
case actorstypes.Version6:
return make6(store)
case actors.Version7:
case actorstypes.Version7:
return make7(store)
case actors.Version8:
case actorstypes.Version8:
return make8(store)
case actorstypes.Version9:
return make9(store)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
var (
Address = builtin8.CronActorAddr
Methods = builtin8.MethodsCron
Address = builtin9.CronActorAddr
Methods = builtin9.MethodsCron
)
type State interface {

View File

@ -0,0 +1,35 @@
package cron
import (
"github.com/ipfs/go-cid"
cron9 "github.com/filecoin-project/go-state-types/builtin/v9/cron"
"github.com/filecoin-project/lotus/chain/actors/adt"
)
var _ State = (*state9)(nil)
func load9(store adt.Store, root cid.Cid) (State, error) {
out := state9{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make9(store adt.Store) (State, error) {
out := state9{store: store}
out.State = *cron9.ConstructState(cron9.BuiltInEntries())
return &out, nil
}
type state9 struct {
cron9.State
store adt.Store
}
func (s *state9) GetState() interface{} {
return &s.State
}

View File

@ -1,6 +1,7 @@
package init
import (
actorstypes "github.com/filecoin-project/go-state-types/actors"
"github.com/filecoin-project/lotus/chain/actors"
"golang.org/x/xerrors"
@ -15,10 +16,9 @@ import (
{{range .versions}}
{{if (le . 7)}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
{{else}}
builtin{{.}} "github.com/filecoin-project/go-state-types/builtin"
{{end}}
{{end}}
builtin{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin"
)
var (
@ -35,7 +35,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
switch av {
{{range .versions}}
{{if (ge . 8)}}
case actors.Version{{.}}:
case actorstypes.Version{{.}}:
return load{{.}}(store, act.Head)
{{end}}
{{end}}
@ -54,10 +54,10 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version, networkName string) (State, error) {
func MakeState(store adt.Store, av actorstypes.Version, networkName string) (State, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
case actorstypes.Version{{.}}:
return make{{.}}(store, networkName)
{{end}}
}

View File

@ -6,7 +6,8 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
builtin8 "github.com/filecoin-project/go-state-types/builtin"
actorstypes "github.com/filecoin-project/go-state-types/actors"
builtin9 "github.com/filecoin-project/go-state-types/builtin"
"github.com/filecoin-project/go-state-types/cbor"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
@ -23,8 +24,8 @@ import (
)
var (
Address = builtin8.InitActorAddr
Methods = builtin8.MethodsInit
Address = builtin9.InitActorAddr
Methods = builtin9.MethodsInit
)
func Load(store adt.Store, act *types.Actor) (State, error) {
@ -35,9 +36,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
switch av {
case actors.Version8:
case actorstypes.Version8:
return load8(store, act.Head)
case actorstypes.Version9:
return load9(store, act.Head)
}
}
@ -69,33 +73,36 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version, networkName string) (State, error) {
func MakeState(store adt.Store, av actorstypes.Version, networkName string) (State, error) {
switch av {
case actors.Version0:
case actorstypes.Version0:
return make0(store, networkName)
case actors.Version2:
case actorstypes.Version2:
return make2(store, networkName)
case actors.Version3:
case actorstypes.Version3:
return make3(store, networkName)
case actors.Version4:
case actorstypes.Version4:
return make4(store, networkName)
case actors.Version5:
case actorstypes.Version5:
return make5(store, networkName)
case actors.Version6:
case actorstypes.Version6:
return make6(store, networkName)
case actors.Version7:
case actorstypes.Version7:
return make7(store, networkName)
case actors.Version8:
case actorstypes.Version8:
return make8(store, networkName)
case actorstypes.Version9:
return make9(store, networkName)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}

View File

@ -0,0 +1,113 @@
package init
import (
"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"
builtin9 "github.com/filecoin-project/go-state-types/builtin"
init9 "github.com/filecoin-project/go-state-types/builtin/v9/init"
adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/node/modules/dtypes"
)
var _ State = (*state9)(nil)
func load9(store adt.Store, root cid.Cid) (State, error) {
out := state9{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make9(store adt.Store, networkName string) (State, error) {
out := state9{store: store}
s, err := init9.ConstructState(store, networkName)
if err != nil {
return nil, err
}
out.State = *s
return &out, nil
}
type state9 struct {
init9.State
store adt.Store
}
func (s *state9) ResolveAddress(address address.Address) (address.Address, bool, error) {
return s.State.ResolveAddress(s.store, address)
}
func (s *state9) MapAddressToNewID(address address.Address) (address.Address, error) {
return s.State.MapAddressToNewID(s.store, address)
}
func (s *state9) ForEachActor(cb func(id abi.ActorID, address address.Address) error) error {
addrs, err := adt9.AsMap(s.store, s.State.AddressMap, builtin9.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 *state9) NetworkName() (dtypes.NetworkName, error) {
return dtypes.NetworkName(s.State.NetworkName), nil
}
func (s *state9) SetNetworkName(name string) error {
s.State.NetworkName = name
return nil
}
func (s *state9) SetNextID(id abi.ActorID) error {
s.State.NextID = id
return nil
}
func (s *state9) Remove(addrs ...address.Address) (err error) {
m, err := adt9.AsMap(s.store, s.State.AddressMap, builtin9.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 *state9) SetAddressMap(mcid cid.Cid) error {
s.State.AddressMap = mcid
return nil
}
func (s *state9) AddressMap() (adt.Map, error) {
return adt9.AsMap(s.store, s.State.AddressMap, builtin9.DefaultHamtBitwidth)
}
func (s *state9) GetState() interface{} {
return &s.State
}

View File

@ -1,6 +1,7 @@
package market
import (
actorstypes "github.com/filecoin-project/go-state-types/actors"
"unicode/utf8"
"github.com/filecoin-project/go-state-types/network"
@ -12,23 +13,23 @@ import (
"github.com/filecoin-project/go-state-types/cbor"
cbg "github.com/whyrusleeping/cbor-gen"
market{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin{{import .latestVersion}}market"
markettypes "github.com/filecoin-project/go-state-types/builtin/v8/market"
{{range .versions}}
{{if (le . 7)}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
{{else}}
builtin{{.}} "github.com/filecoin-project/go-state-types/builtin"
{{end}}
{{end}}
builtintypes "github.com/filecoin-project/go-state-types/builtin"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/types"
)
var (
Address = builtin{{.latestVersion}}.StorageMarketActorAddr
Methods = builtin{{.latestVersion}}.MethodsMarket
Address = builtintypes.StorageMarketActorAddr
Methods = builtintypes.MethodsMarket
)
func Load(store adt.Store, act *types.Actor) (State, error) {
@ -40,7 +41,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
switch av {
{{range .versions}}
{{if (ge . 8)}}
case actors.Version{{.}}:
case actorstypes.Version{{.}}:
return load{{.}}(store, act.Head)
{{end}}
{{end}}
@ -59,10 +60,10 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version) (State, error) {
func MakeState(store adt.Store, av actorstypes.Version) (State, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
case actorstypes.Version{{.}}:
return make{{.}}(store)
{{end}}
}
@ -100,11 +101,11 @@ type DealStates interface {
}
type DealProposals interface {
ForEach(cb func(id abi.DealID, dp market{{.latestVersion}}.DealProposal) error) error
Get(id abi.DealID) (*market{{.latestVersion}}.DealProposal, bool, error)
ForEach(cb func(id abi.DealID, dp markettypes.DealProposal) error) error
Get(id abi.DealID) (*markettypes.DealProposal, bool, error)
array() adt.Array
decode(*cbg.Deferred) (*market{{.latestVersion}}.DealProposal, error)
decode(*cbg.Deferred) (*markettypes.DealProposal, error)
}
@ -115,23 +116,24 @@ type PublishStorageDealsReturn interface {
}
func DecodePublishStorageDealsReturn(b []byte, nv network.Version) (PublishStorageDealsReturn, error) {
av, err := actors.VersionForNetwork(nv)
av, err := actorstypes.VersionForNetwork(nv)
if err != nil {
return nil, err
}
switch av {
{{range .versions}}
case actors.Version{{.}}:
case actorstypes.Version{{.}}:
return decodePublishStorageDealsReturn{{.}}(b)
{{end}}
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
type DealProposal = market{{.latestVersion}}.DealProposal
type DealProposal = markettypes.DealProposal
type DealLabel = markettypes.DealLabel
type DealState = market{{.latestVersion}}.DealState
type DealState = markettypes.DealState
type DealStateChanges struct {
Added []DealIDState
@ -158,7 +160,7 @@ type DealProposalChanges struct {
type ProposalIDState struct {
ID abi.DealID
Proposal market{{.latestVersion}}.DealProposal
Proposal markettypes.DealProposal
}
func EmptyDealState() *DealState {
@ -170,7 +172,7 @@ func EmptyDealState() *DealState {
}
// returns the earned fees and pending fees for a given deal
func GetDealFees(deal market{{.latestVersion}}.DealProposal, height abi.ChainEpoch) (abi.TokenAmount, abi.TokenAmount) {
func GetDealFees(deal markettypes.DealProposal, height abi.ChainEpoch) (abi.TokenAmount, abi.TokenAmount) {
tf := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(deal.EndEpoch-deal.StartEpoch)))
ef := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(height-deal.StartEpoch)))
@ -185,14 +187,14 @@ func GetDealFees(deal market{{.latestVersion}}.DealProposal, height abi.ChainEpo
return ef, big.Sub(tf, ef)
}
func IsDealActive(state market{{.latestVersion}}.DealState) bool {
func IsDealActive(state markettypes.DealState) bool {
return state.SectorStartEpoch > -1 && state.SlashEpoch == -1
}
func labelFromGoString(s string) (market{{.latestVersion}}.DealLabel, error) {
func labelFromGoString(s string) (markettypes.DealLabel, error) {
if utf8.ValidString(s) {
return market{{.latestVersion}}.NewLabelFromString(s)
return markettypes.NewLabelFromString(s)
} else {
return market{{.latestVersion}}.NewLabelFromBytes([]byte(s))
return markettypes.NewLabelFromBytes([]byte(s))
}
}

View File

@ -8,9 +8,10 @@ import (
"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"
builtin8 "github.com/filecoin-project/go-state-types/builtin"
market8 "github.com/filecoin-project/go-state-types/builtin/v8/market"
builtintypes "github.com/filecoin-project/go-state-types/builtin"
markettypes "github.com/filecoin-project/go-state-types/builtin/v8/market"
"github.com/filecoin-project/go-state-types/cbor"
"github.com/filecoin-project/go-state-types/network"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
@ -27,8 +28,8 @@ import (
)
var (
Address = builtin8.StorageMarketActorAddr
Methods = builtin8.MethodsMarket
Address = builtintypes.StorageMarketActorAddr
Methods = builtintypes.MethodsMarket
)
func Load(store adt.Store, act *types.Actor) (State, error) {
@ -39,9 +40,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
switch av {
case actors.Version8:
case actorstypes.Version8:
return load8(store, act.Head)
case actorstypes.Version9:
return load9(store, act.Head)
}
}
@ -73,33 +77,36 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version) (State, error) {
func MakeState(store adt.Store, av actorstypes.Version) (State, error) {
switch av {
case actors.Version0:
case actorstypes.Version0:
return make0(store)
case actors.Version2:
case actorstypes.Version2:
return make2(store)
case actors.Version3:
case actorstypes.Version3:
return make3(store)
case actors.Version4:
case actorstypes.Version4:
return make4(store)
case actors.Version5:
case actorstypes.Version5:
return make5(store)
case actors.Version6:
case actorstypes.Version6:
return make6(store)
case actors.Version7:
case actorstypes.Version7:
return make7(store)
case actors.Version8:
case actorstypes.Version8:
return make8(store)
case actorstypes.Version9:
return make9(store)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
@ -135,11 +142,11 @@ type DealStates interface {
}
type DealProposals interface {
ForEach(cb func(id abi.DealID, dp market8.DealProposal) error) error
Get(id abi.DealID) (*market8.DealProposal, bool, error)
ForEach(cb func(id abi.DealID, dp markettypes.DealProposal) error) error
Get(id abi.DealID) (*markettypes.DealProposal, bool, error)
array() adt.Array
decode(*cbg.Deferred) (*market8.DealProposal, error)
decode(*cbg.Deferred) (*markettypes.DealProposal, error)
}
type PublishStorageDealsReturn interface {
@ -149,44 +156,48 @@ type PublishStorageDealsReturn interface {
}
func DecodePublishStorageDealsReturn(b []byte, nv network.Version) (PublishStorageDealsReturn, error) {
av, err := actors.VersionForNetwork(nv)
av, err := actorstypes.VersionForNetwork(nv)
if err != nil {
return nil, err
}
switch av {
case actors.Version0:
case actorstypes.Version0:
return decodePublishStorageDealsReturn0(b)
case actors.Version2:
case actorstypes.Version2:
return decodePublishStorageDealsReturn2(b)
case actors.Version3:
case actorstypes.Version3:
return decodePublishStorageDealsReturn3(b)
case actors.Version4:
case actorstypes.Version4:
return decodePublishStorageDealsReturn4(b)
case actors.Version5:
case actorstypes.Version5:
return decodePublishStorageDealsReturn5(b)
case actors.Version6:
case actorstypes.Version6:
return decodePublishStorageDealsReturn6(b)
case actors.Version7:
case actorstypes.Version7:
return decodePublishStorageDealsReturn7(b)
case actors.Version8:
case actorstypes.Version8:
return decodePublishStorageDealsReturn8(b)
case actorstypes.Version9:
return decodePublishStorageDealsReturn9(b)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
type DealProposal = market8.DealProposal
type DealProposal = markettypes.DealProposal
type DealLabel = markettypes.DealLabel
type DealState = market8.DealState
type DealState = markettypes.DealState
type DealStateChanges struct {
Added []DealIDState
@ -213,7 +224,7 @@ type DealProposalChanges struct {
type ProposalIDState struct {
ID abi.DealID
Proposal market8.DealProposal
Proposal markettypes.DealProposal
}
func EmptyDealState() *DealState {
@ -225,7 +236,7 @@ func EmptyDealState() *DealState {
}
// returns the earned fees and pending fees for a given deal
func GetDealFees(deal market8.DealProposal, height abi.ChainEpoch) (abi.TokenAmount, abi.TokenAmount) {
func GetDealFees(deal markettypes.DealProposal, height abi.ChainEpoch) (abi.TokenAmount, abi.TokenAmount) {
tf := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(deal.EndEpoch-deal.StartEpoch)))
ef := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(height-deal.StartEpoch)))
@ -240,14 +251,14 @@ func GetDealFees(deal market8.DealProposal, height abi.ChainEpoch) (abi.TokenAmo
return ef, big.Sub(tf, ef)
}
func IsDealActive(state market8.DealState) bool {
func IsDealActive(state markettypes.DealState) bool {
return state.SectorStartEpoch > -1 && state.SlashEpoch == -1
}
func labelFromGoString(s string) (market8.DealLabel, error) {
func labelFromGoString(s string) (markettypes.DealLabel, error) {
if utf8.ValidString(s) {
return market8.NewLabelFromString(s)
return markettypes.NewLabelFromString(s)
} else {
return market8.NewLabelFromBytes([]byte(s))
return markettypes.NewLabelFromBytes([]byte(s))
}
}

View File

@ -22,7 +22,8 @@ import (
adt{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/util/adt"
{{else}}
market{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}market"
adt{{.v}} "github.com/filecoin-project/go-state-types/builtin/v8/util/adt"
markettypes "github.com/filecoin-project/go-state-types/builtin/v8/market"
adt{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}util/adt"
{{end}}
)
@ -258,12 +259,12 @@ func (s *dealProposals{{.v}}) array() adt.Array {
func fromV{{.v}}DealProposal(v{{.v}} market{{.v}}.DealProposal) (DealProposal, error) {
{{if (le .v 7)}}
label, err := labelFromGoString(v{{.v}}.Label)
{{else}}
label, err := fromV{{.v}}Label(v{{.v}}.Label)
{{end}}
if err != nil {
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
}
{{else}}
label := v{{.v}}.Label
{{end}}
return DealProposal{
PieceCID: v{{.v}}.PieceCID,
@ -283,6 +284,25 @@ func fromV{{.v}}DealProposal(v{{.v}} market{{.v}}.DealProposal) (DealProposal, e
}, nil
}
{{if (ge .v 8)}}
func fromV{{.v}}Label(v{{.v}} market{{.v}}.DealLabel) (DealLabel, error) {
if v{{.v}}.IsString() {
str, err := v{{.v}}.ToString()
if err != nil {
return markettypes.EmptyDealLabel, xerrors.Errorf("failed to convert string label to string: %w", err)
}
return markettypes.NewLabelFromString(str)
}
bs, err := v{{.v}}.ToBytes()
if err != nil {
return markettypes.EmptyDealLabel, xerrors.Errorf("failed to convert bytes label to bytes: %w", err)
}
return markettypes.NewLabelFromBytes(bs)
}
{{end}}
func (s *state{{.v}}) GetState() interface{} {
return &s.State

View File

@ -241,6 +241,7 @@ func (s *dealProposals0) array() adt.Array {
func fromV0DealProposal(v0 market0.DealProposal) (DealProposal, error) {
label, err := labelFromGoString(v0.Label)
if err != nil {
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
}

View File

@ -241,6 +241,7 @@ func (s *dealProposals2) array() adt.Array {
func fromV2DealProposal(v2 market2.DealProposal) (DealProposal, error) {
label, err := labelFromGoString(v2.Label)
if err != nil {
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
}

View File

@ -236,6 +236,7 @@ func (s *dealProposals3) array() adt.Array {
func fromV3DealProposal(v3 market3.DealProposal) (DealProposal, error) {
label, err := labelFromGoString(v3.Label)
if err != nil {
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
}

View File

@ -236,6 +236,7 @@ func (s *dealProposals4) array() adt.Array {
func fromV4DealProposal(v4 market4.DealProposal) (DealProposal, error) {
label, err := labelFromGoString(v4.Label)
if err != nil {
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
}

View File

@ -236,6 +236,7 @@ func (s *dealProposals5) array() adt.Array {
func fromV5DealProposal(v5 market5.DealProposal) (DealProposal, error) {
label, err := labelFromGoString(v5.Label)
if err != nil {
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
}

View File

@ -238,6 +238,7 @@ func (s *dealProposals6) array() adt.Array {
func fromV6DealProposal(v6 market6.DealProposal) (DealProposal, error) {
label, err := labelFromGoString(v6.Label)
if err != nil {
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
}

View File

@ -238,6 +238,7 @@ func (s *dealProposals7) array() adt.Array {
func fromV7DealProposal(v7 market7.DealProposal) (DealProposal, error) {
label, err := labelFromGoString(v7.Label)
if err != nil {
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
}

View File

@ -12,6 +12,7 @@ import (
rlepluslazy "github.com/filecoin-project/go-bitfield/rle"
"github.com/filecoin-project/go-state-types/abi"
market8 "github.com/filecoin-project/go-state-types/builtin/v8/market"
markettypes "github.com/filecoin-project/go-state-types/builtin/v8/market"
adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt"
"github.com/filecoin-project/lotus/chain/actors/adt"
@ -237,7 +238,11 @@ func (s *dealProposals8) array() adt.Array {
func fromV8DealProposal(v8 market8.DealProposal) (DealProposal, error) {
label := v8.Label
label, err := fromV8Label(v8.Label)
if err != nil {
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
}
return DealProposal{
PieceCID: v8.PieceCID,
@ -257,6 +262,22 @@ func fromV8DealProposal(v8 market8.DealProposal) (DealProposal, error) {
}, nil
}
func fromV8Label(v8 market8.DealLabel) (DealLabel, error) {
if v8.IsString() {
str, err := v8.ToString()
if err != nil {
return markettypes.EmptyDealLabel, xerrors.Errorf("failed to convert string label to string: %w", err)
}
return markettypes.NewLabelFromString(str)
}
bs, err := v8.ToBytes()
if err != nil {
return markettypes.EmptyDealLabel, xerrors.Errorf("failed to convert bytes label to bytes: %w", err)
}
return markettypes.NewLabelFromBytes(bs)
}
func (s *state8) GetState() interface{} {
return &s.State
}

View File

@ -0,0 +1,325 @@
package market
import (
"bytes"
"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"
markettypes "github.com/filecoin-project/go-state-types/builtin/v8/market"
market9 "github.com/filecoin-project/go-state-types/builtin/v9/market"
adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/types"
)
var _ State = (*state9)(nil)
func load9(store adt.Store, root cid.Cid) (State, error) {
out := state9{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make9(store adt.Store) (State, error) {
out := state9{store: store}
s, err := market9.ConstructState(store)
if err != nil {
return nil, err
}
out.State = *s
return &out, nil
}
type state9 struct {
market9.State
store adt.Store
}
func (s *state9) TotalLocked() (abi.TokenAmount, error) {
fml := types.BigAdd(s.TotalClientLockedCollateral, s.TotalProviderLockedCollateral)
fml = types.BigAdd(fml, s.TotalClientStorageFee)
return fml, nil
}
func (s *state9) BalancesChanged(otherState State) (bool, error) {
otherState9, ok := otherState.(*state9)
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(otherState9.State.EscrowTable) || !s.State.LockedTable.Equals(otherState9.State.LockedTable), nil
}
func (s *state9) StatesChanged(otherState State) (bool, error) {
otherState9, ok := otherState.(*state9)
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(otherState9.State.States), nil
}
func (s *state9) States() (DealStates, error) {
stateArray, err := adt9.AsArray(s.store, s.State.States, market9.StatesAmtBitwidth)
if err != nil {
return nil, err
}
return &dealStates9{stateArray}, nil
}
func (s *state9) ProposalsChanged(otherState State) (bool, error) {
otherState9, ok := otherState.(*state9)
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(otherState9.State.Proposals), nil
}
func (s *state9) Proposals() (DealProposals, error) {
proposalArray, err := adt9.AsArray(s.store, s.State.Proposals, market9.ProposalsAmtBitwidth)
if err != nil {
return nil, err
}
return &dealProposals9{proposalArray}, nil
}
func (s *state9) EscrowTable() (BalanceTable, error) {
bt, err := adt9.AsBalanceTable(s.store, s.State.EscrowTable)
if err != nil {
return nil, err
}
return &balanceTable9{bt}, nil
}
func (s *state9) LockedTable() (BalanceTable, error) {
bt, err := adt9.AsBalanceTable(s.store, s.State.LockedTable)
if err != nil {
return nil, err
}
return &balanceTable9{bt}, nil
}
func (s *state9) VerifyDealsForActivation(
minerAddr address.Address, deals []abi.DealID, currEpoch, sectorExpiry abi.ChainEpoch,
) (weight, verifiedWeight abi.DealWeight, err error) {
w, vw, _, err := market9.ValidateDealsForActivation(&s.State, s.store, deals, minerAddr, sectorExpiry, currEpoch)
return w, vw, err
}
func (s *state9) NextID() (abi.DealID, error) {
return s.State.NextID, nil
}
type balanceTable9 struct {
*adt9.BalanceTable
}
func (bt *balanceTable9) ForEach(cb func(address.Address, abi.TokenAmount) error) error {
asMap := (*adt9.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 dealStates9 struct {
adt.Array
}
func (s *dealStates9) Get(dealID abi.DealID) (*DealState, bool, error) {
var deal9 market9.DealState
found, err := s.Array.Get(uint64(dealID), &deal9)
if err != nil {
return nil, false, err
}
if !found {
return nil, false, nil
}
deal := fromV9DealState(deal9)
return &deal, true, nil
}
func (s *dealStates9) ForEach(cb func(dealID abi.DealID, ds DealState) error) error {
var ds9 market9.DealState
return s.Array.ForEach(&ds9, func(idx int64) error {
return cb(abi.DealID(idx), fromV9DealState(ds9))
})
}
func (s *dealStates9) decode(val *cbg.Deferred) (*DealState, error) {
var ds9 market9.DealState
if err := ds9.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return nil, err
}
ds := fromV9DealState(ds9)
return &ds, nil
}
func (s *dealStates9) array() adt.Array {
return s.Array
}
func fromV9DealState(v9 market9.DealState) DealState {
return (DealState)(v9)
}
type dealProposals9 struct {
adt.Array
}
func (s *dealProposals9) Get(dealID abi.DealID) (*DealProposal, bool, error) {
var proposal9 market9.DealProposal
found, err := s.Array.Get(uint64(dealID), &proposal9)
if err != nil {
return nil, false, err
}
if !found {
return nil, false, nil
}
proposal, err := fromV9DealProposal(proposal9)
if err != nil {
return nil, true, xerrors.Errorf("decoding proposal: %w", err)
}
return &proposal, true, nil
}
func (s *dealProposals9) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error {
var dp9 market9.DealProposal
return s.Array.ForEach(&dp9, func(idx int64) error {
dp, err := fromV9DealProposal(dp9)
if err != nil {
return xerrors.Errorf("decoding proposal: %w", err)
}
return cb(abi.DealID(idx), dp)
})
}
func (s *dealProposals9) decode(val *cbg.Deferred) (*DealProposal, error) {
var dp9 market9.DealProposal
if err := dp9.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return nil, err
}
dp, err := fromV9DealProposal(dp9)
if err != nil {
return nil, err
}
return &dp, nil
}
func (s *dealProposals9) array() adt.Array {
return s.Array
}
func fromV9DealProposal(v9 market9.DealProposal) (DealProposal, error) {
label, err := fromV9Label(v9.Label)
if err != nil {
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
}
return DealProposal{
PieceCID: v9.PieceCID,
PieceSize: v9.PieceSize,
VerifiedDeal: v9.VerifiedDeal,
Client: v9.Client,
Provider: v9.Provider,
Label: label,
StartEpoch: v9.StartEpoch,
EndEpoch: v9.EndEpoch,
StoragePricePerEpoch: v9.StoragePricePerEpoch,
ProviderCollateral: v9.ProviderCollateral,
ClientCollateral: v9.ClientCollateral,
}, nil
}
func fromV9Label(v9 market9.DealLabel) (DealLabel, error) {
if v9.IsString() {
str, err := v9.ToString()
if err != nil {
return markettypes.EmptyDealLabel, xerrors.Errorf("failed to convert string label to string: %w", err)
}
return markettypes.NewLabelFromString(str)
}
bs, err := v9.ToBytes()
if err != nil {
return markettypes.EmptyDealLabel, xerrors.Errorf("failed to convert bytes label to bytes: %w", err)
}
return markettypes.NewLabelFromBytes(bs)
}
func (s *state9) GetState() interface{} {
return &s.State
}
var _ PublishStorageDealsReturn = (*publishStorageDealsReturn9)(nil)
func decodePublishStorageDealsReturn9(b []byte) (PublishStorageDealsReturn, error) {
var retval market9.PublishStorageDealsReturn
if err := retval.UnmarshalCBOR(bytes.NewReader(b)); err != nil {
return nil, xerrors.Errorf("failed to unmarshal PublishStorageDealsReturn: %w", err)
}
return &publishStorageDealsReturn9{retval}, nil
}
type publishStorageDealsReturn9 struct {
market9.PublishStorageDealsReturn
}
func (r *publishStorageDealsReturn9) 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 *publishStorageDealsReturn9) DealIDs() ([]abi.DealID, error) {
return r.IDs, nil
}

View File

@ -1,6 +1,7 @@
package miner
import (
actorstypes "github.com/filecoin-project/go-state-types/actors"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/lotus/chain/actors"
@ -33,7 +34,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
switch av {
{{range .versions}}
{{if (ge . 8)}}
case actors.Version{{.}}:
case actorstypes.Version{{.}}:
return load{{.}}(store, act.Head)
{{end}}
{{end}}
@ -201,6 +202,7 @@ func WinningPoStProofTypeFromWindowPoStProofType(nver network.Version, proof abi
type MinerInfo = miner{{.latestVersion}}.MinerInfo
type WorkerKeyChange = miner{{.latestVersion}}.WorkerKeyChange
type SectorPreCommitOnChainInfo = miner{{.latestVersion}}.SectorPreCommitOnChainInfo
type WindowPostVerifyInfo = proof.WindowPoStVerifyInfo
type SectorExpiration struct {

View File

@ -6,8 +6,9 @@ import (
"github.com/filecoin-project/go-bitfield"
"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"
miner8 "github.com/filecoin-project/go-state-types/builtin/v8/miner"
miner9 "github.com/filecoin-project/go-state-types/builtin/v9/miner"
"github.com/filecoin-project/go-state-types/cbor"
"github.com/filecoin-project/go-state-types/dline"
"github.com/filecoin-project/go-state-types/network"
@ -33,9 +34,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
switch av {
case actors.Version8:
case actorstypes.Version8:
return load8(store, act.Head)
case actorstypes.Version9:
return load9(store, act.Head)
}
}
@ -94,6 +98,9 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
case actors.Version8:
return make8(store)
case actors.Version9:
return make9(store)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
@ -112,8 +119,8 @@ type State interface {
GetSector(abi.SectorNumber) (*SectorOnChainInfo, error)
FindSector(abi.SectorNumber) (*SectorLocation, error)
GetSectorExpiration(abi.SectorNumber) (*SectorExpiration, error)
GetPrecommittedSector(abi.SectorNumber) (*miner8.SectorPreCommitOnChainInfo, error)
ForEachPrecommittedSector(func(miner8.SectorPreCommitOnChainInfo) error) error
GetPrecommittedSector(abi.SectorNumber) (*miner9.SectorPreCommitOnChainInfo, error)
ForEachPrecommittedSector(func(miner9.SectorPreCommitOnChainInfo) error) error
LoadSectors(sectorNos *bitfield.BitField) ([]*SectorOnChainInfo, error)
NumLiveSectors() (uint64, error)
IsAllocated(abi.SectorNumber) (bool, error)
@ -142,7 +149,7 @@ type State interface {
sectors() (adt.Array, error)
decodeSectorOnChainInfo(*cbg.Deferred) (SectorOnChainInfo, error)
precommits() (adt.Map, error)
decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (miner8.SectorPreCommitOnChainInfo, error)
decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (miner9.SectorPreCommitOnChainInfo, error)
GetState() interface{}
}
@ -180,7 +187,7 @@ type Partition interface {
UnprovenSectors() (bitfield.BitField, error)
}
type SectorOnChainInfo = miner8.SectorOnChainInfo
type SectorOnChainInfo = miner9.SectorOnChainInfo
func PreferredSealProofTypeFromWindowPoStType(nver network.Version, proof abi.RegisteredPoStProof) (abi.RegisteredSealProof, error) {
// We added support for the new proofs in network version 7, and removed support for the old
@ -235,8 +242,9 @@ func WinningPoStProofTypeFromWindowPoStProofType(nver network.Version, proof abi
}
}
type MinerInfo = miner8.MinerInfo
type WorkerKeyChange = miner8.WorkerKeyChange
type MinerInfo = miner9.MinerInfo
type WorkerKeyChange = miner9.WorkerKeyChange
type SectorPreCommitOnChainInfo = miner9.SectorPreCommitOnChainInfo
type WindowPostVerifyInfo = proof.WindowPoStVerifyInfo
type SectorExpiration struct {
@ -264,8 +272,8 @@ type SectorExtensions struct {
}
type PreCommitChanges struct {
Added []miner8.SectorPreCommitOnChainInfo
Removed []miner8.SectorPreCommitOnChainInfo
Added []miner9.SectorPreCommitOnChainInfo
Removed []miner9.SectorPreCommitOnChainInfo
}
type LockedFunds struct {

View File

@ -15,7 +15,7 @@ import (
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/chain/actors/adt"
minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner"
minertypes "github.com/filecoin-project/go-state-types/builtin/v{{.latestVersion}}/miner"
{{if (le .v 7)}}
{{if (ge .v 3)}}
@ -581,11 +581,17 @@ func fromV{{.v}}SectorOnChainInfo(v{{.v}} miner{{.v}}.SectorOnChainInfo) SectorO
func fromV{{.v}}SectorPreCommitOnChainInfo(v{{.v}} miner{{.v}}.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo {
return minertypes.SectorPreCommitOnChainInfo{
Info: (minertypes.SectorPreCommitInfo)(v{{.v}}.Info),
Info: minertypes.SectorPreCommitInfo{
SealProof: v{{.v}}.Info.SealProof,
SectorNumber: v{{.v}}.Info.SectorNumber,
SealedCID: v{{.v}}.Info.SealedCID,
SealRandEpoch: v{{.v}}.Info.SealRandEpoch,
DealIDs: v{{.v}}.Info.DealIDs,
Expiration: v{{.v}}.Info.Expiration,
UnsealedCid: nil,
},
PreCommitDeposit: v{{.v}}.PreCommitDeposit,
PreCommitEpoch: v{{.v}}.PreCommitEpoch,
DealWeight: v{{.v}}.DealWeight,
VerifiedDealWeight: v{{.v}}.VerifiedDealWeight,
}
}

View File

@ -12,7 +12,7 @@ import (
rle "github.com/filecoin-project/go-bitfield/rle"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner"
minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner"
"github.com/filecoin-project/go-state-types/dline"
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
adt0 "github.com/filecoin-project/specs-actors/actors/util/adt"
@ -511,11 +511,17 @@ func fromV0SectorOnChainInfo(v0 miner0.SectorOnChainInfo) SectorOnChainInfo {
func fromV0SectorPreCommitOnChainInfo(v0 miner0.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo {
return minertypes.SectorPreCommitOnChainInfo{
Info: (minertypes.SectorPreCommitInfo)(v0.Info),
Info: minertypes.SectorPreCommitInfo{
SealProof: v0.Info.SealProof,
SectorNumber: v0.Info.SectorNumber,
SealedCID: v0.Info.SealedCID,
SealRandEpoch: v0.Info.SealRandEpoch,
DealIDs: v0.Info.DealIDs,
Expiration: v0.Info.Expiration,
UnsealedCid: nil,
},
PreCommitDeposit: v0.PreCommitDeposit,
PreCommitEpoch: v0.PreCommitEpoch,
DealWeight: v0.DealWeight,
VerifiedDealWeight: v0.VerifiedDealWeight,
}
}

View File

@ -11,7 +11,7 @@ import (
"github.com/filecoin-project/go-bitfield"
rle "github.com/filecoin-project/go-bitfield/rle"
"github.com/filecoin-project/go-state-types/abi"
minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner"
minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner"
"github.com/filecoin-project/go-state-types/dline"
miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt"
@ -542,11 +542,17 @@ func fromV2SectorOnChainInfo(v2 miner2.SectorOnChainInfo) SectorOnChainInfo {
func fromV2SectorPreCommitOnChainInfo(v2 miner2.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo {
return minertypes.SectorPreCommitOnChainInfo{
Info: (minertypes.SectorPreCommitInfo)(v2.Info),
Info: minertypes.SectorPreCommitInfo{
SealProof: v2.Info.SealProof,
SectorNumber: v2.Info.SectorNumber,
SealedCID: v2.Info.SealedCID,
SealRandEpoch: v2.Info.SealRandEpoch,
DealIDs: v2.Info.DealIDs,
Expiration: v2.Info.Expiration,
UnsealedCid: nil,
},
PreCommitDeposit: v2.PreCommitDeposit,
PreCommitEpoch: v2.PreCommitEpoch,
DealWeight: v2.DealWeight,
VerifiedDealWeight: v2.VerifiedDealWeight,
}
}

View File

@ -11,7 +11,7 @@ import (
"github.com/filecoin-project/go-bitfield"
rle "github.com/filecoin-project/go-bitfield/rle"
"github.com/filecoin-project/go-state-types/abi"
minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner"
minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner"
"github.com/filecoin-project/go-state-types/dline"
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"
miner3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/miner"
@ -542,11 +542,17 @@ func fromV3SectorOnChainInfo(v3 miner3.SectorOnChainInfo) SectorOnChainInfo {
func fromV3SectorPreCommitOnChainInfo(v3 miner3.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo {
return minertypes.SectorPreCommitOnChainInfo{
Info: (minertypes.SectorPreCommitInfo)(v3.Info),
Info: minertypes.SectorPreCommitInfo{
SealProof: v3.Info.SealProof,
SectorNumber: v3.Info.SectorNumber,
SealedCID: v3.Info.SealedCID,
SealRandEpoch: v3.Info.SealRandEpoch,
DealIDs: v3.Info.DealIDs,
Expiration: v3.Info.Expiration,
UnsealedCid: nil,
},
PreCommitDeposit: v3.PreCommitDeposit,
PreCommitEpoch: v3.PreCommitEpoch,
DealWeight: v3.DealWeight,
VerifiedDealWeight: v3.VerifiedDealWeight,
}
}

View File

@ -11,7 +11,7 @@ import (
"github.com/filecoin-project/go-bitfield"
rle "github.com/filecoin-project/go-bitfield/rle"
"github.com/filecoin-project/go-state-types/abi"
minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner"
minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner"
"github.com/filecoin-project/go-state-types/dline"
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"
miner4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/miner"
@ -542,11 +542,17 @@ func fromV4SectorOnChainInfo(v4 miner4.SectorOnChainInfo) SectorOnChainInfo {
func fromV4SectorPreCommitOnChainInfo(v4 miner4.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo {
return minertypes.SectorPreCommitOnChainInfo{
Info: (minertypes.SectorPreCommitInfo)(v4.Info),
Info: minertypes.SectorPreCommitInfo{
SealProof: v4.Info.SealProof,
SectorNumber: v4.Info.SectorNumber,
SealedCID: v4.Info.SealedCID,
SealRandEpoch: v4.Info.SealRandEpoch,
DealIDs: v4.Info.DealIDs,
Expiration: v4.Info.Expiration,
UnsealedCid: nil,
},
PreCommitDeposit: v4.PreCommitDeposit,
PreCommitEpoch: v4.PreCommitEpoch,
DealWeight: v4.DealWeight,
VerifiedDealWeight: v4.VerifiedDealWeight,
}
}

View File

@ -11,7 +11,7 @@ import (
"github.com/filecoin-project/go-bitfield"
rle "github.com/filecoin-project/go-bitfield/rle"
"github.com/filecoin-project/go-state-types/abi"
minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner"
minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner"
"github.com/filecoin-project/go-state-types/dline"
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner"
@ -542,11 +542,17 @@ func fromV5SectorOnChainInfo(v5 miner5.SectorOnChainInfo) SectorOnChainInfo {
func fromV5SectorPreCommitOnChainInfo(v5 miner5.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo {
return minertypes.SectorPreCommitOnChainInfo{
Info: (minertypes.SectorPreCommitInfo)(v5.Info),
Info: minertypes.SectorPreCommitInfo{
SealProof: v5.Info.SealProof,
SectorNumber: v5.Info.SectorNumber,
SealedCID: v5.Info.SealedCID,
SealRandEpoch: v5.Info.SealRandEpoch,
DealIDs: v5.Info.DealIDs,
Expiration: v5.Info.Expiration,
UnsealedCid: nil,
},
PreCommitDeposit: v5.PreCommitDeposit,
PreCommitEpoch: v5.PreCommitEpoch,
DealWeight: v5.DealWeight,
VerifiedDealWeight: v5.VerifiedDealWeight,
}
}

View File

@ -11,7 +11,7 @@ import (
"github.com/filecoin-project/go-bitfield"
rle "github.com/filecoin-project/go-bitfield/rle"
"github.com/filecoin-project/go-state-types/abi"
minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner"
minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner"
"github.com/filecoin-project/go-state-types/dline"
builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"
miner6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/miner"
@ -542,11 +542,17 @@ func fromV6SectorOnChainInfo(v6 miner6.SectorOnChainInfo) SectorOnChainInfo {
func fromV6SectorPreCommitOnChainInfo(v6 miner6.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo {
return minertypes.SectorPreCommitOnChainInfo{
Info: (minertypes.SectorPreCommitInfo)(v6.Info),
Info: minertypes.SectorPreCommitInfo{
SealProof: v6.Info.SealProof,
SectorNumber: v6.Info.SectorNumber,
SealedCID: v6.Info.SealedCID,
SealRandEpoch: v6.Info.SealRandEpoch,
DealIDs: v6.Info.DealIDs,
Expiration: v6.Info.Expiration,
UnsealedCid: nil,
},
PreCommitDeposit: v6.PreCommitDeposit,
PreCommitEpoch: v6.PreCommitEpoch,
DealWeight: v6.DealWeight,
VerifiedDealWeight: v6.VerifiedDealWeight,
}
}

View File

@ -11,7 +11,7 @@ import (
"github.com/filecoin-project/go-bitfield"
rle "github.com/filecoin-project/go-bitfield/rle"
"github.com/filecoin-project/go-state-types/abi"
minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner"
minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner"
"github.com/filecoin-project/go-state-types/dline"
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
miner7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/miner"
@ -543,11 +543,17 @@ func fromV7SectorOnChainInfo(v7 miner7.SectorOnChainInfo) SectorOnChainInfo {
func fromV7SectorPreCommitOnChainInfo(v7 miner7.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo {
return minertypes.SectorPreCommitOnChainInfo{
Info: (minertypes.SectorPreCommitInfo)(v7.Info),
Info: minertypes.SectorPreCommitInfo{
SealProof: v7.Info.SealProof,
SectorNumber: v7.Info.SectorNumber,
SealedCID: v7.Info.SealedCID,
SealRandEpoch: v7.Info.SealRandEpoch,
DealIDs: v7.Info.DealIDs,
Expiration: v7.Info.Expiration,
UnsealedCid: nil,
},
PreCommitDeposit: v7.PreCommitDeposit,
PreCommitEpoch: v7.PreCommitEpoch,
DealWeight: v7.DealWeight,
VerifiedDealWeight: v7.VerifiedDealWeight,
}
}

View File

@ -13,8 +13,8 @@ import (
"github.com/filecoin-project/go-state-types/abi"
builtin8 "github.com/filecoin-project/go-state-types/builtin"
miner8 "github.com/filecoin-project/go-state-types/builtin/v8/miner"
minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner"
adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt"
minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner"
"github.com/filecoin-project/go-state-types/dline"
"github.com/filecoin-project/lotus/chain/actors/adt"
@ -543,11 +543,17 @@ func fromV8SectorOnChainInfo(v8 miner8.SectorOnChainInfo) SectorOnChainInfo {
func fromV8SectorPreCommitOnChainInfo(v8 miner8.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo {
return minertypes.SectorPreCommitOnChainInfo{
Info: (minertypes.SectorPreCommitInfo)(v8.Info),
Info: minertypes.SectorPreCommitInfo{
SealProof: v8.Info.SealProof,
SectorNumber: v8.Info.SectorNumber,
SealedCID: v8.Info.SealedCID,
SealRandEpoch: v8.Info.SealRandEpoch,
DealIDs: v8.Info.DealIDs,
Expiration: v8.Info.Expiration,
UnsealedCid: nil,
},
PreCommitDeposit: v8.PreCommitDeposit,
PreCommitEpoch: v8.PreCommitEpoch,
DealWeight: v8.DealWeight,
VerifiedDealWeight: v8.VerifiedDealWeight,
}
}

View File

@ -0,0 +1,562 @@
package miner
import (
"bytes"
"errors"
"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"
builtin9 "github.com/filecoin-project/go-state-types/builtin"
miner9 "github.com/filecoin-project/go-state-types/builtin/v9/miner"
minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner"
adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt"
"github.com/filecoin-project/go-state-types/dline"
"github.com/filecoin-project/lotus/chain/actors/adt"
)
var _ State = (*state9)(nil)
func load9(store adt.Store, root cid.Cid) (State, error) {
out := state9{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make9(store adt.Store) (State, error) {
out := state9{store: store}
out.State = miner9.State{}
return &out, nil
}
type state9 struct {
miner9.State
store adt.Store
}
type deadline9 struct {
miner9.Deadline
store adt.Store
}
type partition9 struct {
miner9.Partition
store adt.Store
}
func (s *state9) 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 *state9) VestedFunds(epoch abi.ChainEpoch) (abi.TokenAmount, error) {
return s.CheckVestedFunds(s.store, epoch)
}
func (s *state9) LockedFunds() (LockedFunds, error) {
return LockedFunds{
VestingFunds: s.State.LockedFunds,
InitialPledgeRequirement: s.State.InitialPledge,
PreCommitDeposits: s.State.PreCommitDeposits,
}, nil
}
func (s *state9) FeeDebt() (abi.TokenAmount, error) {
return s.State.FeeDebt, nil
}
func (s *state9) InitialPledge() (abi.TokenAmount, error) {
return s.State.InitialPledge, nil
}
func (s *state9) PreCommitDeposits() (abi.TokenAmount, error) {
return s.State.PreCommitDeposits, nil
}
func (s *state9) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) {
info, ok, err := s.State.GetSector(s.store, num)
if !ok || err != nil {
return nil, err
}
ret := fromV9SectorOnChainInfo(*info)
return &ret, nil
}
func (s *state9) 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 *state9) 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 *miner9.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 *state9) 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 *miner9.Deadline) error {
partitions, err := dl.PartitionsArray(s.store)
if err != nil {
return err
}
quant := s.State.QuantSpecForDeadline(dlIdx)
var part miner9.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 := miner9.LoadExpirationQueue(s.store, part.ExpirationsEpochs, quant, miner9.PartitionExpirationAmtBitwidth)
if err != nil {
return err
}
var exp miner9.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 *state9) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) {
info, ok, err := s.State.GetPrecommittedSector(s.store, num)
if !ok || err != nil {
return nil, err
}
ret := fromV9SectorPreCommitOnChainInfo(*info)
return &ret, nil
}
func (s *state9) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error {
precommitted, err := adt9.AsMap(s.store, s.State.PreCommittedSectors, builtin9.DefaultHamtBitwidth)
if err != nil {
return err
}
var info miner9.SectorPreCommitOnChainInfo
if err := precommitted.ForEach(&info, func(_ string) error {
return cb(fromV9SectorPreCommitOnChainInfo(info))
}); err != nil {
return err
}
return nil
}
func (s *state9) LoadSectors(snos *bitfield.BitField) ([]*SectorOnChainInfo, error) {
sectors, err := miner9.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 info9 miner9.SectorOnChainInfo
if err := sectors.ForEach(&info9, func(_ int64) error {
info := fromV9SectorOnChainInfo(info9)
infos = append(infos, &info)
return nil
}); err != nil {
return nil, err
}
return infos, nil
}
// Otherwise, load selected.
infos9, err := sectors.Load(*snos)
if err != nil {
return nil, err
}
infos := make([]*SectorOnChainInfo, len(infos9))
for i, info9 := range infos9 {
info := fromV9SectorOnChainInfo(*info9)
infos[i] = &info
}
return infos, nil
}
func (s *state9) loadAllocatedSectorNumbers() (bitfield.BitField, error) {
var allocatedSectors bitfield.BitField
err := s.store.Get(s.store.Context(), s.State.AllocatedSectors, &allocatedSectors)
return allocatedSectors, err
}
func (s *state9) IsAllocated(num abi.SectorNumber) (bool, error) {
allocatedSectors, err := s.loadAllocatedSectorNumbers()
if err != nil {
return false, err
}
return allocatedSectors.IsSet(uint64(num))
}
func (s *state9) GetProvingPeriodStart() (abi.ChainEpoch, error) {
return s.State.ProvingPeriodStart, nil
}
func (s *state9) 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 *state9) 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 *state9) 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 &deadline9{*dl, s.store}, nil
}
func (s *state9) 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 *miner9.Deadline) error {
return cb(i, &deadline9{*dl, s.store})
})
}
func (s *state9) NumDeadlines() (uint64, error) {
return miner9.WPoStPeriodDeadlines, nil
}
func (s *state9) DeadlinesChanged(other State) (bool, error) {
other9, ok := other.(*state9)
if !ok {
// treat an upgrade as a change, always
return true, nil
}
return !s.State.Deadlines.Equals(other9.Deadlines), nil
}
func (s *state9) MinerInfoChanged(other State) (bool, error) {
other0, ok := other.(*state9)
if !ok {
// treat an upgrade as a change, always
return true, nil
}
return !s.State.Info.Equals(other0.State.Info), nil
}
func (s *state9) 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,
}
return mi, nil
}
func (s *state9) DeadlineInfo(epoch abi.ChainEpoch) (*dline.Info, error) {
return s.State.RecordedDeadlineInfo(epoch), nil
}
func (s *state9) DeadlineCronActive() (bool, error) {
return s.State.DeadlineCronActive, nil
}
func (s *state9) sectors() (adt.Array, error) {
return adt9.AsArray(s.store, s.Sectors, miner9.SectorsAmtBitwidth)
}
func (s *state9) decodeSectorOnChainInfo(val *cbg.Deferred) (SectorOnChainInfo, error) {
var si miner9.SectorOnChainInfo
err := si.UnmarshalCBOR(bytes.NewReader(val.Raw))
if err != nil {
return SectorOnChainInfo{}, err
}
return fromV9SectorOnChainInfo(si), nil
}
func (s *state9) precommits() (adt.Map, error) {
return adt9.AsMap(s.store, s.PreCommittedSectors, builtin9.DefaultHamtBitwidth)
}
func (s *state9) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) {
var sp miner9.SectorPreCommitOnChainInfo
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
if err != nil {
return minertypes.SectorPreCommitOnChainInfo{}, err
}
return fromV9SectorPreCommitOnChainInfo(sp), nil
}
func (s *state9) EraseAllUnproven() error {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return err
}
err = dls.ForEach(s.store, func(dindx uint64, dl *miner9.Deadline) error {
ps, err := dl.PartitionsArray(s.store)
if err != nil {
return err
}
var part miner9.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 *deadline9) LoadPartition(idx uint64) (Partition, error) {
p, err := d.Deadline.LoadPartition(d.store, idx)
if err != nil {
return nil, err
}
return &partition9{*p, d.store}, nil
}
func (d *deadline9) ForEachPartition(cb func(uint64, Partition) error) error {
ps, err := d.Deadline.PartitionsArray(d.store)
if err != nil {
return err
}
var part miner9.Partition
return ps.ForEach(&part, func(i int64) error {
return cb(uint64(i), &partition9{part, d.store})
})
}
func (d *deadline9) PartitionsChanged(other Deadline) (bool, error) {
other9, ok := other.(*deadline9)
if !ok {
// treat an upgrade as a change, always
return true, nil
}
return !d.Deadline.Partitions.Equals(other9.Deadline.Partitions), nil
}
func (d *deadline9) PartitionsPoSted() (bitfield.BitField, error) {
return d.Deadline.PartitionsPoSted, nil
}
func (d *deadline9) DisputableProofCount() (uint64, error) {
ops, err := d.OptimisticProofsSnapshotArray(d.store)
if err != nil {
return 0, err
}
return ops.Length(), nil
}
func (p *partition9) AllSectors() (bitfield.BitField, error) {
return p.Partition.Sectors, nil
}
func (p *partition9) FaultySectors() (bitfield.BitField, error) {
return p.Partition.Faults, nil
}
func (p *partition9) RecoveringSectors() (bitfield.BitField, error) {
return p.Partition.Recoveries, nil
}
func (p *partition9) UnprovenSectors() (bitfield.BitField, error) {
return p.Partition.Unproven, nil
}
func fromV9SectorOnChainInfo(v9 miner9.SectorOnChainInfo) SectorOnChainInfo {
info := SectorOnChainInfo{
SectorNumber: v9.SectorNumber,
SealProof: v9.SealProof,
SealedCID: v9.SealedCID,
DealIDs: v9.DealIDs,
Activation: v9.Activation,
Expiration: v9.Expiration,
DealWeight: v9.DealWeight,
VerifiedDealWeight: v9.VerifiedDealWeight,
InitialPledge: v9.InitialPledge,
ExpectedDayReward: v9.ExpectedDayReward,
ExpectedStoragePledge: v9.ExpectedStoragePledge,
SectorKeyCID: v9.SectorKeyCID,
}
return info
}
func fromV9SectorPreCommitOnChainInfo(v9 miner9.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo {
return minertypes.SectorPreCommitOnChainInfo{
Info: minertypes.SectorPreCommitInfo{
SealProof: v9.Info.SealProof,
SectorNumber: v9.Info.SectorNumber,
SealedCID: v9.Info.SealedCID,
SealRandEpoch: v9.Info.SealRandEpoch,
DealIDs: v9.Info.DealIDs,
Expiration: v9.Info.Expiration,
UnsealedCid: nil,
},
PreCommitDeposit: v9.PreCommitDeposit,
PreCommitEpoch: v9.PreCommitEpoch,
}
}
func (s *state9) GetState() interface{} {
return &s.State
}

View File

@ -1,6 +1,7 @@
package multisig
import (
actorstypes "github.com/filecoin-project/go-state-types/actors"
"fmt"
"github.com/minio/blake2b-simd"
@ -15,11 +16,11 @@ import (
{{range .versions}}
{{if (le . 7)}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
{{else}}
builtin{{.}} "github.com/filecoin-project/go-state-types/builtin"
{{end}}
{{end}}
builtintypes "github.com/filecoin-project/go-state-types/builtin"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/types"
@ -34,7 +35,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
switch av {
{{range .versions}}
{{if (ge . 8)}}
case actors.Version{{.}}:
case actorstypes.Version{{.}}:
return load{{.}}(store, act.Head)
{{end}}
{{end}}
@ -53,10 +54,10 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) {
func MakeState(store adt.Store, av actorstypes.Version, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
case actorstypes.Version{{.}}:
return make{{.}}(store, signers, threshold, startEpoch, unlockDuration, initialBalance)
{{end}}
}
@ -83,12 +84,12 @@ type State interface {
type Transaction = msig{{.latestVersion}}.Transaction
var Methods = builtin{{.latestVersion}}.MethodsMultisig
var Methods = builtintypes.MethodsMultisig
func Message(version actors.Version, from address.Address) MessageBuilder {
func Message(version actorstypes.Version, from address.Address) MessageBuilder {
switch version {
{{range .versions}}
case actors.Version{{.}}:
case actorstypes.Version{{.}}:
return message{{.}}{{"{"}}{{if (ge . 2)}}message0{from}{{else}}from{{end}}}
{{end}} default:
panic(fmt.Sprintf("unsupported actors version: %d", version))

View File

@ -11,12 +11,12 @@ import (
init{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/init"
multisig{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/multisig"
{{else}}
builtin{{.v}} "github.com/filecoin-project/go-state-types/builtin"
multisig{{.v}} "github.com/filecoin-project/go-state-types/builtin/v8/multisig"
init{{.v}} "github.com/filecoin-project/go-state-types/builtin/v8/init"
actorstypes "github.com/filecoin-project/go-state-types/actors"
multisig{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}multisig"
init{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin/v{{.latestVersion}}/init"
{{end}}
builtintypes "github.com/filecoin-project/go-state-types/builtin"
"github.com/filecoin-project/lotus/chain/actors"
init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init"
"github.com/filecoin-project/lotus/chain/types"
@ -68,13 +68,13 @@ func (m message{{.v}}) Create(
ConstructorParams: enc,
}
{{else}}
code, ok := actors.GetActorCodeID(actors.Version{{.v}}, actors.MultisigKey)
code, ok := actors.GetActorCodeID(actorstypes.Version{{.v}}, actors.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 := &init8.ExecParams{
execParams := &init{{.latestVersion}}.ExecParams{
CodeCID: code,
ConstructorParams: enc,
}
@ -88,7 +88,7 @@ func (m message{{.v}}) Create(
return &types.Message{
To: init_.Address,
From: m.from,
Method: builtin{{.v}}.MethodsInit.Exec,
Method: builtintypes.MethodsInit.Exec,
Params: enc,
Value: initialAmount,
}, nil

View File

@ -5,6 +5,7 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
builtintypes "github.com/filecoin-project/go-state-types/builtin"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
init0 "github.com/filecoin-project/specs-actors/actors/builtin/init"
multisig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
@ -66,7 +67,7 @@ func (m message0) Create(
return &types.Message{
To: init_.Address,
From: m.from,
Method: builtin0.MethodsInit.Exec,
Method: builtintypes.MethodsInit.Exec,
Params: enc,
Value: initialAmount,
}, nil

View File

@ -5,6 +5,7 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
builtintypes "github.com/filecoin-project/go-state-types/builtin"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
init2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/init"
multisig2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/multisig"
@ -63,7 +64,7 @@ func (m message2) Create(
return &types.Message{
To: init_.Address,
From: m.from,
Method: builtin2.MethodsInit.Exec,
Method: builtintypes.MethodsInit.Exec,
Params: enc,
Value: initialAmount,
}, nil

View File

@ -5,6 +5,7 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
builtintypes "github.com/filecoin-project/go-state-types/builtin"
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"
init3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/init"
multisig3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/multisig"
@ -63,7 +64,7 @@ func (m message3) Create(
return &types.Message{
To: init_.Address,
From: m.from,
Method: builtin3.MethodsInit.Exec,
Method: builtintypes.MethodsInit.Exec,
Params: enc,
Value: initialAmount,
}, nil

View File

@ -5,6 +5,7 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
builtintypes "github.com/filecoin-project/go-state-types/builtin"
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"
init4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/init"
multisig4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/multisig"
@ -63,7 +64,7 @@ func (m message4) Create(
return &types.Message{
To: init_.Address,
From: m.from,
Method: builtin4.MethodsInit.Exec,
Method: builtintypes.MethodsInit.Exec,
Params: enc,
Value: initialAmount,
}, nil

View File

@ -5,6 +5,7 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
builtintypes "github.com/filecoin-project/go-state-types/builtin"
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
init5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/init"
multisig5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/multisig"
@ -63,7 +64,7 @@ func (m message5) Create(
return &types.Message{
To: init_.Address,
From: m.from,
Method: builtin5.MethodsInit.Exec,
Method: builtintypes.MethodsInit.Exec,
Params: enc,
Value: initialAmount,
}, nil

View File

@ -5,6 +5,7 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
builtintypes "github.com/filecoin-project/go-state-types/builtin"
builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"
init6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/init"
multisig6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/multisig"
@ -63,7 +64,7 @@ func (m message6) Create(
return &types.Message{
To: init_.Address,
From: m.from,
Method: builtin6.MethodsInit.Exec,
Method: builtintypes.MethodsInit.Exec,
Params: enc,
Value: initialAmount,
}, nil

View File

@ -5,6 +5,7 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
builtintypes "github.com/filecoin-project/go-state-types/builtin"
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
init7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/init"
multisig7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/multisig"
@ -63,7 +64,7 @@ func (m message7) Create(
return &types.Message{
To: init_.Address,
From: m.from,
Method: builtin7.MethodsInit.Exec,
Method: builtintypes.MethodsInit.Exec,
Params: enc,
Value: initialAmount,
}, nil

View File

@ -5,9 +5,10 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
builtin8 "github.com/filecoin-project/go-state-types/builtin"
init8 "github.com/filecoin-project/go-state-types/builtin/v8/init"
actorstypes "github.com/filecoin-project/go-state-types/actors"
builtintypes "github.com/filecoin-project/go-state-types/builtin"
multisig8 "github.com/filecoin-project/go-state-types/builtin/v8/multisig"
init9 "github.com/filecoin-project/go-state-types/builtin/v9/init"
"github.com/filecoin-project/lotus/chain/actors"
init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init"
@ -49,13 +50,13 @@ func (m message8) Create(
return nil, actErr
}
code, ok := actors.GetActorCodeID(actors.Version8, actors.MultisigKey)
code, ok := actors.GetActorCodeID(actorstypes.Version8, actors.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 := &init8.ExecParams{
execParams := &init9.ExecParams{
CodeCID: code,
ConstructorParams: enc,
}
@ -68,7 +69,7 @@ func (m message8) Create(
return &types.Message{
To: init_.Address,
From: m.from,
Method: builtin8.MethodsInit.Exec,
Method: builtintypes.MethodsInit.Exec,
Params: enc,
Value: initialAmount,
}, nil

View File

@ -0,0 +1,76 @@
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"
init9 "github.com/filecoin-project/go-state-types/builtin/v9/init"
multisig9 "github.com/filecoin-project/go-state-types/builtin/v9/multisig"
"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 message9 struct{ message0 }
func (m message9) 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 := &multisig9.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.Version9, actors.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 := &init9.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

@ -9,8 +9,9 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
builtin8 "github.com/filecoin-project/go-state-types/builtin"
msig8 "github.com/filecoin-project/go-state-types/builtin/v8/multisig"
actorstypes "github.com/filecoin-project/go-state-types/actors"
builtintypes "github.com/filecoin-project/go-state-types/builtin"
msig9 "github.com/filecoin-project/go-state-types/builtin/v9/multisig"
"github.com/filecoin-project/go-state-types/cbor"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
@ -33,9 +34,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
switch av {
case actors.Version8:
case actorstypes.Version8:
return load8(store, act.Head)
case actorstypes.Version9:
return load9(store, act.Head)
}
}
@ -67,33 +71,36 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) {
func MakeState(store adt.Store, av actorstypes.Version, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) {
switch av {
case actors.Version0:
case actorstypes.Version0:
return make0(store, signers, threshold, startEpoch, unlockDuration, initialBalance)
case actors.Version2:
case actorstypes.Version2:
return make2(store, signers, threshold, startEpoch, unlockDuration, initialBalance)
case actors.Version3:
case actorstypes.Version3:
return make3(store, signers, threshold, startEpoch, unlockDuration, initialBalance)
case actors.Version4:
case actorstypes.Version4:
return make4(store, signers, threshold, startEpoch, unlockDuration, initialBalance)
case actors.Version5:
case actorstypes.Version5:
return make5(store, signers, threshold, startEpoch, unlockDuration, initialBalance)
case actors.Version6:
case actorstypes.Version6:
return make6(store, signers, threshold, startEpoch, unlockDuration, initialBalance)
case actors.Version7:
case actorstypes.Version7:
return make7(store, signers, threshold, startEpoch, unlockDuration, initialBalance)
case actors.Version8:
case actorstypes.Version8:
return make8(store, signers, threshold, startEpoch, unlockDuration, initialBalance)
case actorstypes.Version9:
return make9(store, signers, threshold, startEpoch, unlockDuration, initialBalance)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
@ -116,36 +123,39 @@ type State interface {
GetState() interface{}
}
type Transaction = msig8.Transaction
type Transaction = msig9.Transaction
var Methods = builtin8.MethodsMultisig
var Methods = builtintypes.MethodsMultisig
func Message(version actors.Version, from address.Address) MessageBuilder {
func Message(version actorstypes.Version, from address.Address) MessageBuilder {
switch version {
case actors.Version0:
case actorstypes.Version0:
return message0{from}
case actors.Version2:
case actorstypes.Version2:
return message2{message0{from}}
case actors.Version3:
case actorstypes.Version3:
return message3{message0{from}}
case actors.Version4:
case actorstypes.Version4:
return message4{message0{from}}
case actors.Version5:
case actorstypes.Version5:
return message5{message0{from}}
case actors.Version6:
case actorstypes.Version6:
return message6{message0{from}}
case actors.Version7:
case actorstypes.Version7:
return message7{message0{from}}
case actors.Version8:
case actorstypes.Version8:
return message8{message0{from}}
case actorstypes.Version9:
return message9{message0{from}}
default:
panic(fmt.Sprintf("unsupported actors version: %d", version))
}
@ -169,13 +179,13 @@ type MessageBuilder interface {
}
// this type is the same between v0 and v2
type ProposalHashData = msig8.ProposalHashData
type ProposeReturn = msig8.ProposeReturn
type ProposeParams = msig8.ProposeParams
type ApproveReturn = msig8.ApproveReturn
type ProposalHashData = msig9.ProposalHashData
type ProposeReturn = msig9.ProposeReturn
type ProposeParams = msig9.ProposeParams
type ApproveReturn = msig9.ApproveReturn
func txnParams(id uint64, data *ProposalHashData) ([]byte, error) {
params := msig8.TxnIDParams{ID: msig8.TxnID(id)}
params := msig9.TxnIDParams{ID: msig9.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)

View File

@ -0,0 +1,117 @@
package multisig
import (
"bytes"
"encoding/binary"
"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"
builtin9 "github.com/filecoin-project/go-state-types/builtin"
msig9 "github.com/filecoin-project/go-state-types/builtin/v9/multisig"
adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt"
"github.com/filecoin-project/lotus/chain/actors/adt"
)
var _ State = (*state9)(nil)
func load9(store adt.Store, root cid.Cid) (State, error) {
out := state9{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make9(store adt.Store, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) {
out := state9{store: store}
out.State = msig9.State{}
out.State.Signers = signers
out.State.NumApprovalsThreshold = threshold
out.State.StartEpoch = startEpoch
out.State.UnlockDuration = unlockDuration
out.State.InitialBalance = initialBalance
em, err := adt9.StoreEmptyMap(store, builtin9.DefaultHamtBitwidth)
if err != nil {
return nil, err
}
out.State.PendingTxns = em
return &out, nil
}
type state9 struct {
msig9.State
store adt.Store
}
func (s *state9) LockedBalance(currEpoch abi.ChainEpoch) (abi.TokenAmount, error) {
return s.State.AmountLocked(currEpoch - s.State.StartEpoch), nil
}
func (s *state9) StartEpoch() (abi.ChainEpoch, error) {
return s.State.StartEpoch, nil
}
func (s *state9) UnlockDuration() (abi.ChainEpoch, error) {
return s.State.UnlockDuration, nil
}
func (s *state9) InitialBalance() (abi.TokenAmount, error) {
return s.State.InitialBalance, nil
}
func (s *state9) Threshold() (uint64, error) {
return s.State.NumApprovalsThreshold, nil
}
func (s *state9) Signers() ([]address.Address, error) {
return s.State.Signers, nil
}
func (s *state9) ForEachPendingTxn(cb func(id int64, txn Transaction) error) error {
arr, err := adt9.AsMap(s.store, s.State.PendingTxns, builtin9.DefaultHamtBitwidth)
if err != nil {
return err
}
var out msig9.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 *state9) PendingTxnChanged(other State) (bool, error) {
other9, ok := other.(*state9)
if !ok {
// treat an upgrade as a change, always
return true, nil
}
return !s.State.PendingTxns.Equals(other9.PendingTxns), nil
}
func (s *state9) transactions() (adt.Map, error) {
return adt9.AsMap(s.store, s.PendingTxns, builtin9.DefaultHamtBitwidth)
}
func (s *state9) decodeTransaction(val *cbg.Deferred) (Transaction, error) {
var tx msig9.Transaction
if err := tx.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return Transaction{}, err
}
return Transaction(tx), nil
}
func (s *state9) GetState() interface{} {
return &s.State
}

View File

@ -1,6 +1,7 @@
package paych
import (
actorstypes "github.com/filecoin-project/go-state-types/actors"
"encoding/base64"
"fmt"
@ -35,7 +36,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
switch av {
{{range .versions}}
{{if (ge . 8)}}
case actors.Version{{.}}:
case actorstypes.Version{{.}}:
return load{{.}}(store, act.Head)
{{end}}
{{end}}
@ -99,10 +100,10 @@ func DecodeSignedVoucher(s string) (*paychtypes.SignedVoucher, error) {
return &sv, nil
}
func Message(version actors.Version, from address.Address) MessageBuilder {
func Message(version actorstypes.Version, from address.Address) MessageBuilder {
switch version {
{{range .versions}}
case actors.Version{{.}}:
case actorstypes.Version{{.}}:
return message{{.}}{from}
{{end}}
default:

View File

@ -14,9 +14,10 @@ import (
init{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/init"
paych{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/paych"
{{else}}
actorstypes "github.com/filecoin-project/go-state-types/actors"
builtin{{.v}} "github.com/filecoin-project/go-state-types/builtin"
paych{{.v}} "github.com/filecoin-project/go-state-types/builtin/v8/paych"
init{{.v}} "github.com/filecoin-project/go-state-types/builtin/v8/init"
paych{{.v}} "github.com/filecoin-project/go-state-types/builtin/v{{.v}}/paych"
init{{.v}} "github.com/filecoin-project/go-state-types/builtin/v{{.v}}/init"
{{end}}
@ -31,7 +32,7 @@ func (m message{{.v}}) Create(to address.Address, initialAmount abi.TokenAmount)
{{if (le .v 7)}}
actorCodeID := builtin{{.v}}.PaymentChannelActorCodeID
{{else}}
actorCodeID, ok := actors.GetActorCodeID(actors.Version{{.v}}, "paymentchannel")
actorCodeID, ok := actors.GetActorCodeID(actorstypes.Version{{.v}}, "paymentchannel")
if !ok {
return nil, xerrors.Errorf("error getting actor paymentchannel code id for actor version %d", {{.v}})
}
@ -62,8 +63,10 @@ func (m message{{.v}}) Update(paych address.Address, sv *paychtypes.SignedVouche
params, aerr := actors.SerializeParams(&paych{{.v}}.UpdateChannelStateParams{
{{if (le .v 6)}}
Sv: toV0SignedVoucher(*sv),
{{else}}
{{else if (le .v 8)}}
Sv: *sv,
{{else}}
Sv: toV{{.v}}SignedVoucher(*sv),
{{end}}
Secret: secret,
})
@ -80,6 +83,32 @@ func (m message{{.v}}) Update(paych address.Address, sv *paychtypes.SignedVouche
}, nil
}
{{if (ge .v 9)}}
func toV{{.v}}SignedVoucher(sv paychtypes.SignedVoucher) paych{{.v}}.SignedVoucher {
merges := make([]paych{{.v}}.Merge, len(sv.Merges))
for i := range sv.Merges {
merges[i] = paych{{.v}}.Merge{
Lane: sv.Merges[i].Lane,
Nonce: sv.Merges[i].Nonce,
}
}
return paych{{.v}}.SignedVoucher{
ChannelAddr: sv.ChannelAddr,
TimeLockMin: sv.TimeLockMin,
TimeLockMax: sv.TimeLockMax,
SecretHash: sv.SecretHash,
Extra: (*paych{{.v}}.ModVerifyParams)(sv.Extra),
Lane: sv.Lane,
Nonce: sv.Nonce,
Amount: sv.Amount,
MinSettleHeight: sv.MinSettleHeight,
Merges: merges,
Signature: sv.Signature,
}
}
{{end}}
func (m message{{.v}}) Settle(paych address.Address) (*types.Message, error) {
return &types.Message{
To: paych,

View File

@ -5,6 +5,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"
builtin8 "github.com/filecoin-project/go-state-types/builtin"
init8 "github.com/filecoin-project/go-state-types/builtin/v8/init"
paych8 "github.com/filecoin-project/go-state-types/builtin/v8/paych"
@ -19,7 +20,7 @@ type message8 struct{ from address.Address }
func (m message8) Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error) {
actorCodeID, ok := actors.GetActorCodeID(actors.Version8, "paymentchannel")
actorCodeID, ok := actors.GetActorCodeID(actorstypes.Version8, "paymentchannel")
if !ok {
return nil, xerrors.Errorf("error getting actor paymentchannel code id for actor version %d", 8)
}

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

View File

@ -9,6 +9,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"
"github.com/filecoin-project/go-state-types/big"
paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych"
"github.com/filecoin-project/go-state-types/cbor"
@ -35,9 +36,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
switch av {
case actors.Version8:
case actorstypes.Version8:
return load8(store, act.Head)
case actorstypes.Version9:
return load9(store, act.Head)
}
}
@ -114,33 +118,36 @@ func DecodeSignedVoucher(s string) (*paychtypes.SignedVoucher, error) {
return &sv, nil
}
func Message(version actors.Version, from address.Address) MessageBuilder {
func Message(version actorstypes.Version, from address.Address) MessageBuilder {
switch version {
case actors.Version0:
case actorstypes.Version0:
return message0{from}
case actors.Version2:
case actorstypes.Version2:
return message2{from}
case actors.Version3:
case actorstypes.Version3:
return message3{from}
case actors.Version4:
case actorstypes.Version4:
return message4{from}
case actors.Version5:
case actorstypes.Version5:
return message5{from}
case actors.Version6:
case actorstypes.Version6:
return message6{from}
case actors.Version7:
case actorstypes.Version7:
return message7{from}
case actors.Version8:
case actorstypes.Version8:
return message8{from}
case actorstypes.Version9:
return message9{from}
default:
panic(fmt.Sprintf("unsupported actors version: %d", version))
}

View File

@ -0,0 +1,113 @@
package paych
import (
"github.com/ipfs/go-cid"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
paych9 "github.com/filecoin-project/go-state-types/builtin/v9/paych"
adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt"
"github.com/filecoin-project/lotus/chain/actors/adt"
)
var _ State = (*state9)(nil)
func load9(store adt.Store, root cid.Cid) (State, error) {
out := state9{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make9(store adt.Store) (State, error) {
out := state9{store: store}
out.State = paych9.State{}
return &out, nil
}
type state9 struct {
paych9.State
store adt.Store
lsAmt *adt9.Array
}
// Channel owner, who has funded the actor
func (s *state9) From() (address.Address, error) {
return s.State.From, nil
}
// Recipient of payouts from channel
func (s *state9) To() (address.Address, error) {
return s.State.To, nil
}
// Height at which the channel can be `Collected`
func (s *state9) SettlingAt() (abi.ChainEpoch, error) {
return s.State.SettlingAt, nil
}
// Amount successfully redeemed through the payment channel, paid out on `Collect()`
func (s *state9) ToSend() (abi.TokenAmount, error) {
return s.State.ToSend, nil
}
func (s *state9) getOrLoadLsAmt() (*adt9.Array, error) {
if s.lsAmt != nil {
return s.lsAmt, nil
}
// Get the lane state from the chain
lsamt, err := adt9.AsArray(s.store, s.State.LaneStates, paych9.LaneStatesAmtBitwidth)
if err != nil {
return nil, err
}
s.lsAmt = lsamt
return lsamt, nil
}
// Get total number of lanes
func (s *state9) LaneCount() (uint64, error) {
lsamt, err := s.getOrLoadLsAmt()
if err != nil {
return 0, err
}
return lsamt.Length(), nil
}
func (s *state9) GetState() interface{} {
return &s.State
}
// Iterate lane states
func (s *state9) 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 paych9.LaneState
return lsamt.ForEach(&ls, func(i int64) error {
return cb(uint64(i), &laneState9{ls})
})
}
type laneState9 struct {
paych9.LaneState
}
func (ls *laneState9) Redeemed() (big.Int, error) {
return ls.LaneState.Redeemed, nil
}
func (ls *laneState9) Nonce() (uint64, error) {
return ls.LaneState.Nonce, nil
}

View File

@ -1,6 +1,7 @@
package power
import (
actorstypes "github.com/filecoin-project/go-state-types/actors"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/lotus/chain/actors"
@ -17,10 +18,9 @@ import (
{{range .versions}}
{{if (le . 7)}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
{{else}}
builtin{{.}} "github.com/filecoin-project/go-state-types/builtin"
{{end}}
{{end}}
builtin{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin"
)
var (
@ -37,7 +37,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
switch av {
{{range .versions}}
{{if (ge . 8)}}
case actors.Version{{.}}:
case actorstypes.Version{{.}}:
return load{{.}}(store, act.Head)
{{end}}
{{end}}
@ -56,10 +56,10 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version) (State, error) {
func MakeState(store adt.Store, av actorstypes.Version) (State, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
case actorstypes.Version{{.}}:
return make{{.}}(store)
{{end}}
}

View File

@ -6,8 +6,9 @@ import (
"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"
builtin8 "github.com/filecoin-project/go-state-types/builtin"
builtin9 "github.com/filecoin-project/go-state-types/builtin"
"github.com/filecoin-project/go-state-types/cbor"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
@ -24,8 +25,8 @@ import (
)
var (
Address = builtin8.StoragePowerActorAddr
Methods = builtin8.MethodsPower
Address = builtin9.StoragePowerActorAddr
Methods = builtin9.MethodsPower
)
func Load(store adt.Store, act *types.Actor) (State, error) {
@ -36,9 +37,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
switch av {
case actors.Version8:
case actorstypes.Version8:
return load8(store, act.Head)
case actorstypes.Version9:
return load9(store, act.Head)
}
}
@ -70,33 +74,36 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version) (State, error) {
func MakeState(store adt.Store, av actorstypes.Version) (State, error) {
switch av {
case actors.Version0:
case actorstypes.Version0:
return make0(store)
case actors.Version2:
case actorstypes.Version2:
return make2(store)
case actors.Version3:
case actorstypes.Version3:
return make3(store)
case actors.Version4:
case actorstypes.Version4:
return make4(store)
case actors.Version5:
case actorstypes.Version5:
return make5(store)
case actors.Version6:
case actorstypes.Version6:
return make6(store)
case actors.Version7:
case actorstypes.Version7:
return make7(store)
case actors.Version8:
case actorstypes.Version8:
return make8(store)
case actorstypes.Version9:
return make9(store)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}

View File

@ -20,7 +20,7 @@ import (
{{else}}
builtin{{.v}} "github.com/filecoin-project/go-state-types/builtin"
power{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}power"
adt{{.v}} "github.com/filecoin-project/go-state-types/builtin/v8/util/adt"
adt{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}util/adt"
{{end}}
)

View File

@ -0,0 +1,186 @@
package power
import (
"bytes"
"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"
builtin9 "github.com/filecoin-project/go-state-types/builtin"
power9 "github.com/filecoin-project/go-state-types/builtin/v9/power"
adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
)
var _ State = (*state9)(nil)
func load9(store adt.Store, root cid.Cid) (State, error) {
out := state9{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make9(store adt.Store) (State, error) {
out := state9{store: store}
s, err := power9.ConstructState(store)
if err != nil {
return nil, err
}
out.State = *s
return &out, nil
}
type state9 struct {
power9.State
store adt.Store
}
func (s *state9) TotalLocked() (abi.TokenAmount, error) {
return s.TotalPledgeCollateral, nil
}
func (s *state9) 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 *state9) TotalCommitted() (Claim, error) {
return Claim{
RawBytePower: s.TotalBytesCommitted,
QualityAdjPower: s.TotalQABytesCommitted,
}, nil
}
func (s *state9) MinerPower(addr address.Address) (Claim, bool, error) {
claims, err := s.claims()
if err != nil {
return Claim{}, false, err
}
var claim power9.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 *state9) MinerNominalPowerMeetsConsensusMinimum(a address.Address) (bool, error) {
return s.State.MinerNominalPowerMeetsConsensusMinimum(s.store, a)
}
func (s *state9) TotalPowerSmoothed() (builtin.FilterEstimate, error) {
return builtin.FilterEstimate(s.State.ThisEpochQAPowerSmoothed), nil
}
func (s *state9) MinerCounts() (uint64, uint64, error) {
return uint64(s.State.MinerAboveMinPowerCount), uint64(s.State.MinerCount), nil
}
func (s *state9) 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 *state9) ForEachClaim(cb func(miner address.Address, claim Claim) error) error {
claims, err := s.claims()
if err != nil {
return err
}
var claim power9.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 *state9) ClaimsChanged(other State) (bool, error) {
other9, ok := other.(*state9)
if !ok {
// treat an upgrade as a change, always
return true, nil
}
return !s.State.Claims.Equals(other9.State.Claims), nil
}
func (s *state9) SetTotalQualityAdjPower(p abi.StoragePower) error {
s.State.TotalQualityAdjPower = p
return nil
}
func (s *state9) SetTotalRawBytePower(p abi.StoragePower) error {
s.State.TotalRawBytePower = p
return nil
}
func (s *state9) SetThisEpochQualityAdjPower(p abi.StoragePower) error {
s.State.ThisEpochQualityAdjPower = p
return nil
}
func (s *state9) SetThisEpochRawBytePower(p abi.StoragePower) error {
s.State.ThisEpochRawBytePower = p
return nil
}
func (s *state9) GetState() interface{} {
return &s.State
}
func (s *state9) claims() (adt.Map, error) {
return adt9.AsMap(s.store, s.Claims, builtin9.DefaultHamtBitwidth)
}
func (s *state9) decodeClaim(val *cbg.Deferred) (Claim, error) {
var ci power9.Claim
if err := ci.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return Claim{}, err
}
return fromV9Claim(ci), nil
}
func fromV9Claim(v9 power9.Claim) Claim {
return Claim{
RawBytePower: v9.RawBytePower,
QualityAdjPower: v9.QualityAdjPower,
}
}

View File

@ -0,0 +1,217 @@
package builtin
import (
"github.com/ipfs/go-cid"
actorstypes "github.com/filecoin-project/go-state-types/actors"
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"
market8 "github.com/filecoin-project/go-state-types/builtin/v8/market"
miner8 "github.com/filecoin-project/go-state-types/builtin/v8/miner"
multisig8 "github.com/filecoin-project/go-state-types/builtin/v8/multisig"
paych8 "github.com/filecoin-project/go-state-types/builtin/v8/paych"
power8 "github.com/filecoin-project/go-state-types/builtin/v8/power"
reward8 "github.com/filecoin-project/go-state-types/builtin/v8/reward"
system8 "github.com/filecoin-project/go-state-types/builtin/v8/system"
verifreg8 "github.com/filecoin-project/go-state-types/builtin/v8/verifreg"
account9 "github.com/filecoin-project/go-state-types/builtin/v9/account"
cron9 "github.com/filecoin-project/go-state-types/builtin/v9/cron"
_init9 "github.com/filecoin-project/go-state-types/builtin/v9/init"
market9 "github.com/filecoin-project/go-state-types/builtin/v9/market"
miner9 "github.com/filecoin-project/go-state-types/builtin/v9/miner"
multisig9 "github.com/filecoin-project/go-state-types/builtin/v9/multisig"
paych9 "github.com/filecoin-project/go-state-types/builtin/v9/paych"
power9 "github.com/filecoin-project/go-state-types/builtin/v9/power"
reward9 "github.com/filecoin-project/go-state-types/builtin/v9/reward"
system9 "github.com/filecoin-project/go-state-types/builtin/v9/system"
verifreg9 "github.com/filecoin-project/go-state-types/builtin/v9/verifreg"
"github.com/filecoin-project/go-state-types/cbor"
rtt "github.com/filecoin-project/go-state-types/rt"
"github.com/filecoin-project/lotus/chain/actors"
)
var _ rtt.VMActor = (*RegistryEntry)(nil)
type RegistryEntry struct {
state cbor.Er
code cid.Cid
methods []interface{}
}
func (r RegistryEntry) State() cbor.Er {
return r.state
}
func (r RegistryEntry) Exports() []interface{} {
return r.methods
}
func (r RegistryEntry) Code() cid.Cid {
return r.code
}
func MakeRegistry(av actorstypes.Version) []rtt.VMActor {
if av < actorstypes.Version8 {
panic("expected version v8 and up only, use specs-actors for v0-7")
}
registry := make([]rtt.VMActor, 0)
codeIDs, err := actors.GetActorCodeIDs(av)
if err != nil {
panic(err)
}
switch av {
case actorstypes.Version8:
for key, codeID := range codeIDs {
switch key {
case actors.AccountKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: account8.Methods,
state: new(account8.State),
})
case actors.CronKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: cron8.Methods,
state: new(cron8.State),
})
case actors.InitKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: _init8.Methods,
state: new(_init8.State),
})
case actors.MarketKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: market8.Methods,
state: new(market8.State),
})
case actors.MinerKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: miner8.Methods,
state: new(miner8.State),
})
case actors.MultisigKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: multisig8.Methods,
state: new(multisig8.State),
})
case actors.PaychKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: paych8.Methods,
state: new(paych8.State),
})
case actors.PowerKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: power8.Methods,
state: new(power8.State),
})
case actors.RewardKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: reward8.Methods,
state: new(reward8.State),
})
case actors.SystemKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: system8.Methods,
state: new(system8.State),
})
case actors.VerifregKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: verifreg8.Methods,
state: new(verifreg8.State),
})
}
}
case actorstypes.Version9:
for key, codeID := range codeIDs {
switch key {
case actors.AccountKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: account9.Methods,
state: new(account9.State),
})
case actors.CronKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: cron9.Methods,
state: new(cron9.State),
})
case actors.InitKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: _init9.Methods,
state: new(_init9.State),
})
case actors.MarketKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: market9.Methods,
state: new(market9.State),
})
case actors.MinerKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: miner9.Methods,
state: new(miner9.State),
})
case actors.MultisigKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: multisig9.Methods,
state: new(multisig9.State),
})
case actors.PaychKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: paych9.Methods,
state: new(paych9.State),
})
case actors.PowerKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: power9.Methods,
state: new(power9.State),
})
case actors.RewardKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: reward9.Methods,
state: new(reward9.State),
})
case actors.SystemKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: system9.Methods,
state: new(system9.State),
})
case actors.VerifregKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: verifreg9.Methods,
state: new(verifreg9.State),
})
}
}
default:
panic("expected version v8 and up only, use specs-actors for v0-7")
}
return registry
}

View File

@ -0,0 +1,139 @@
package builtin
import (
actorstypes "github.com/filecoin-project/go-state-types/actors"
"github.com/ipfs/go-cid"
{{range .versions}}
{{if (ge . 8)}}
account{{.}} "github.com/filecoin-project/go-state-types/builtin/v{{.}}/account"
cron{{.}} "github.com/filecoin-project/go-state-types/builtin/v{{.}}/cron"
_init{{.}} "github.com/filecoin-project/go-state-types/builtin/v{{.}}/init"
multisig{{.}} "github.com/filecoin-project/go-state-types/builtin/v{{.}}/multisig"
miner{{.}} "github.com/filecoin-project/go-state-types/builtin/v{{.}}/miner"
market{{.}} "github.com/filecoin-project/go-state-types/builtin/v{{.}}/market"
reward{{.}} "github.com/filecoin-project/go-state-types/builtin/v{{.}}/reward"
paych{{.}} "github.com/filecoin-project/go-state-types/builtin/v{{.}}/paych"
power{{.}} "github.com/filecoin-project/go-state-types/builtin/v{{.}}/power"
system{{.}} "github.com/filecoin-project/go-state-types/builtin/v{{.}}/system"
verifreg{{.}} "github.com/filecoin-project/go-state-types/builtin/v{{.}}/verifreg"
{{end}}
{{end}}
"github.com/filecoin-project/go-state-types/cbor"
rtt "github.com/filecoin-project/go-state-types/rt"
"github.com/filecoin-project/lotus/chain/actors"
)
var _ rtt.VMActor = (*RegistryEntry)(nil)
type RegistryEntry struct {
state cbor.Er
code cid.Cid
methods []interface{}
}
func (r RegistryEntry) State() cbor.Er {
return r.state
}
func (r RegistryEntry) Exports() []interface{} {
return r.methods
}
func (r RegistryEntry) Code() cid.Cid {
return r.code
}
func MakeRegistry(av actorstypes.Version) []rtt.VMActor {
if av < actorstypes.Version8 {
panic("expected version v8 and up only, use specs-actors for v0-7")
}
registry := make([]rtt.VMActor, 0)
codeIDs, err := actors.GetActorCodeIDs(av)
if err != nil {
panic(err)
}
switch av {
{{range .versions}}
{{if (ge . 8)}}
case actorstypes.Version{{.}}:
for key, codeID := range codeIDs {
switch key {
case actors.AccountKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: account{{.}}.Methods,
state: new(account{{.}}.State),
})
case actors.CronKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: cron{{.}}.Methods,
state: new(cron{{.}}.State),
})
case actors.InitKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: _init{{.}}.Methods,
state: new(_init{{.}}.State),
})
case actors.MarketKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: market{{.}}.Methods,
state: new(market{{.}}.State),
})
case actors.MinerKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: miner{{.}}.Methods,
state: new(miner{{.}}.State),
})
case actors.MultisigKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: multisig{{.}}.Methods,
state: new(multisig{{.}}.State),
})
case actors.PaychKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: paych{{.}}.Methods,
state: new(paych{{.}}.State),
})
case actors.PowerKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: power{{.}}.Methods,
state: new(power{{.}}.State),
})
case actors.RewardKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: reward{{.}}.Methods,
state: new(reward{{.}}.State),
})
case actors.SystemKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: system{{.}}.Methods,
state: new(system{{.}}.State),
})
case actors.VerifregKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: verifreg{{.}}.Methods,
state: new(verifreg{{.}}.State),
})
}
}
{{end}}
{{end}}
default:
panic("expected version v8 and up only, use specs-actors for v0-7")
}
return registry
}

View File

@ -1,6 +1,7 @@
package reward
import (
actorstypes "github.com/filecoin-project/go-state-types/actors"
"github.com/filecoin-project/go-state-types/abi"
reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward"
"github.com/filecoin-project/lotus/chain/actors"
@ -10,10 +11,9 @@ import (
{{range .versions}}
{{if (le . 7)}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
{{else}}
builtin{{.}} "github.com/filecoin-project/go-state-types/builtin"
{{end}}
{{end}}
builtin{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
@ -34,7 +34,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
switch av {
{{range .versions}}
{{if (ge . 8)}}
case actors.Version{{.}}:
case actorstypes.Version{{.}}:
return load{{.}}(store, act.Head)
{{end}}
{{end}}
@ -53,10 +53,10 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version, currRealizedPower abi.StoragePower) (State, error) {
func MakeState(store adt.Store, av actorstypes.Version, currRealizedPower abi.StoragePower) (State, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
case actorstypes.Version{{.}}:
return make{{.}}(store, currRealizedPower)
{{end}}
}

View File

@ -4,7 +4,8 @@ import (
"golang.org/x/xerrors"
"github.com/filecoin-project/go-state-types/abi"
builtin8 "github.com/filecoin-project/go-state-types/builtin"
actorstypes "github.com/filecoin-project/go-state-types/actors"
builtin9 "github.com/filecoin-project/go-state-types/builtin"
"github.com/filecoin-project/go-state-types/cbor"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward"
@ -22,8 +23,8 @@ import (
)
var (
Address = builtin8.RewardActorAddr
Methods = builtin8.MethodsReward
Address = builtin9.RewardActorAddr
Methods = builtin9.MethodsReward
)
func Load(store adt.Store, act *types.Actor) (State, error) {
@ -34,9 +35,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
switch av {
case actors.Version8:
case actorstypes.Version8:
return load8(store, act.Head)
case actorstypes.Version9:
return load9(store, act.Head)
}
}
@ -68,33 +72,36 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version, currRealizedPower abi.StoragePower) (State, error) {
func MakeState(store adt.Store, av actorstypes.Version, currRealizedPower abi.StoragePower) (State, error) {
switch av {
case actors.Version0:
case actorstypes.Version0:
return make0(store, currRealizedPower)
case actors.Version2:
case actorstypes.Version2:
return make2(store, currRealizedPower)
case actors.Version3:
case actorstypes.Version3:
return make3(store, currRealizedPower)
case actors.Version4:
case actorstypes.Version4:
return make4(store, currRealizedPower)
case actors.Version5:
case actorstypes.Version5:
return make5(store, currRealizedPower)
case actors.Version6:
case actorstypes.Version6:
return make6(store, currRealizedPower)
case actors.Version7:
case actorstypes.Version7:
return make7(store, currRealizedPower)
case actors.Version8:
case actorstypes.Version8:
return make8(store, currRealizedPower)
case actorstypes.Version9:
return make9(store, currRealizedPower)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}

View File

@ -0,0 +1,98 @@
package reward
import (
"github.com/ipfs/go-cid"
"github.com/filecoin-project/go-state-types/abi"
miner9 "github.com/filecoin-project/go-state-types/builtin/v9/miner"
reward9 "github.com/filecoin-project/go-state-types/builtin/v9/reward"
smoothing9 "github.com/filecoin-project/go-state-types/builtin/v9/util/smoothing"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
)
var _ State = (*state9)(nil)
func load9(store adt.Store, root cid.Cid) (State, error) {
out := state9{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make9(store adt.Store, currRealizedPower abi.StoragePower) (State, error) {
out := state9{store: store}
out.State = *reward9.ConstructState(currRealizedPower)
return &out, nil
}
type state9 struct {
reward9.State
store adt.Store
}
func (s *state9) ThisEpochReward() (abi.TokenAmount, error) {
return s.State.ThisEpochReward, nil
}
func (s *state9) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) {
return builtin.FilterEstimate{
PositionEstimate: s.State.ThisEpochRewardSmoothed.PositionEstimate,
VelocityEstimate: s.State.ThisEpochRewardSmoothed.VelocityEstimate,
}, nil
}
func (s *state9) ThisEpochBaselinePower() (abi.StoragePower, error) {
return s.State.ThisEpochBaselinePower, nil
}
func (s *state9) TotalStoragePowerReward() (abi.TokenAmount, error) {
return s.State.TotalStoragePowerReward, nil
}
func (s *state9) EffectiveBaselinePower() (abi.StoragePower, error) {
return s.State.EffectiveBaselinePower, nil
}
func (s *state9) EffectiveNetworkTime() (abi.ChainEpoch, error) {
return s.State.EffectiveNetworkTime, nil
}
func (s *state9) CumsumBaseline() (reward9.Spacetime, error) {
return s.State.CumsumBaseline, nil
}
func (s *state9) CumsumRealized() (reward9.Spacetime, error) {
return s.State.CumsumRealized, nil
}
func (s *state9) InitialPledgeForPower(qaPower abi.StoragePower, networkTotalPledge abi.TokenAmount, networkQAPower *builtin.FilterEstimate, circSupply abi.TokenAmount) (abi.TokenAmount, error) {
return miner9.InitialPledgeForPower(
qaPower,
s.State.ThisEpochBaselinePower,
s.State.ThisEpochRewardSmoothed,
smoothing9.FilterEstimate{
PositionEstimate: networkQAPower.PositionEstimate,
VelocityEstimate: networkQAPower.VelocityEstimate,
},
circSupply,
), nil
}
func (s *state9) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate, sectorWeight abi.StoragePower) (abi.TokenAmount, error) {
return miner9.PreCommitDepositForPower(s.State.ThisEpochRewardSmoothed,
smoothing9.FilterEstimate{
PositionEstimate: networkQAPower.PositionEstimate,
VelocityEstimate: networkQAPower.VelocityEstimate,
},
sectorWeight), nil
}
func (s *state9) GetState() interface{} {
return &s.State
}

View File

@ -1,6 +1,7 @@
package system
import (
actorstypes "github.com/filecoin-project/go-state-types/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/types"
@ -11,10 +12,9 @@ import (
{{range .versions}}
{{if (le . 7)}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
{{else}}
builtin{{.}} "github.com/filecoin-project/go-state-types/builtin"
{{end}}
{{end}}
builtin{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin"
)
var (
@ -30,7 +30,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
switch av {
{{range .versions}}
{{if (ge . 8)}}
case actors.Version{{.}}:
case actorstypes.Version{{.}}:
return load{{.}}(store, act.Head)
{{end}}
{{end}}
@ -49,10 +49,10 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version, builtinActors cid.Cid) (State, error) {
func MakeState(store adt.Store, av actorstypes.Version, builtinActors cid.Cid) (State, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
case actorstypes.Version{{.}}:
return make{{.}}(store{{if (ge . 8)}}, builtinActors{{end}})
{{end}}
}
@ -62,4 +62,5 @@ func MakeState(store adt.Store, av actors.Version, builtinActors cid.Cid) (State
type State interface {
GetState() interface{}
GetBuiltinActors() cid.Cid
SetBuiltinActors(cid.Cid) error
}

View File

@ -7,6 +7,7 @@ import (
{{if (le .v 7)}}
system{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/system"
"golang.org/x/xerrors"
{{else}}
system{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}system"
{{end}}
@ -47,3 +48,12 @@ func (s *state{{.v}}) GetBuiltinActors() cid.Cid {
return s.State.BuiltinActors
{{end}}
}
func (s *state{{.v}}) SetBuiltinActors(c cid.Cid) error {
{{if (le .v 7)}}
return xerrors.New("cannot set manifest cid before v8")
{{else}}
s.State.BuiltinActors = c
return nil
{{end}}
}

View File

@ -4,7 +4,8 @@ import (
"github.com/ipfs/go-cid"
"golang.org/x/xerrors"
builtin8 "github.com/filecoin-project/go-state-types/builtin"
actorstypes "github.com/filecoin-project/go-state-types/actors"
builtin9 "github.com/filecoin-project/go-state-types/builtin"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"
@ -19,7 +20,7 @@ import (
)
var (
Address = builtin8.SystemActorAddr
Address = builtin9.SystemActorAddr
)
func Load(store adt.Store, act *types.Actor) (State, error) {
@ -30,9 +31,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
switch av {
case actors.Version8:
case actorstypes.Version8:
return load8(store, act.Head)
case actorstypes.Version9:
return load9(store, act.Head)
}
}
@ -64,33 +68,36 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version, builtinActors cid.Cid) (State, error) {
func MakeState(store adt.Store, av actorstypes.Version, builtinActors cid.Cid) (State, error) {
switch av {
case actors.Version0:
case actorstypes.Version0:
return make0(store)
case actors.Version2:
case actorstypes.Version2:
return make2(store)
case actors.Version3:
case actorstypes.Version3:
return make3(store)
case actors.Version4:
case actorstypes.Version4:
return make4(store)
case actors.Version5:
case actorstypes.Version5:
return make5(store)
case actors.Version6:
case actorstypes.Version6:
return make6(store)
case actors.Version7:
case actorstypes.Version7:
return make7(store)
case actors.Version8:
case actorstypes.Version8:
return make8(store, builtinActors)
case actorstypes.Version9:
return make9(store, builtinActors)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
@ -98,4 +105,5 @@ func MakeState(store adt.Store, av actors.Version, builtinActors cid.Cid) (State
type State interface {
GetState() interface{}
GetBuiltinActors() cid.Cid
SetBuiltinActors(cid.Cid) error
}

View File

@ -2,6 +2,7 @@ package system
import (
"github.com/ipfs/go-cid"
"golang.org/x/xerrors"
system0 "github.com/filecoin-project/specs-actors/actors/builtin/system"
@ -39,3 +40,9 @@ func (s *state0) GetBuiltinActors() cid.Cid {
return cid.Undef
}
func (s *state0) SetBuiltinActors(c cid.Cid) error {
return xerrors.New("cannot set manifest cid before v8")
}

View File

@ -2,6 +2,7 @@ package system
import (
"github.com/ipfs/go-cid"
"golang.org/x/xerrors"
system2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/system"
@ -39,3 +40,9 @@ func (s *state2) GetBuiltinActors() cid.Cid {
return cid.Undef
}
func (s *state2) SetBuiltinActors(c cid.Cid) error {
return xerrors.New("cannot set manifest cid before v8")
}

View File

@ -2,6 +2,7 @@ package system
import (
"github.com/ipfs/go-cid"
"golang.org/x/xerrors"
system3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/system"
@ -39,3 +40,9 @@ func (s *state3) GetBuiltinActors() cid.Cid {
return cid.Undef
}
func (s *state3) SetBuiltinActors(c cid.Cid) error {
return xerrors.New("cannot set manifest cid before v8")
}

View File

@ -2,6 +2,7 @@ package system
import (
"github.com/ipfs/go-cid"
"golang.org/x/xerrors"
system4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/system"
@ -39,3 +40,9 @@ func (s *state4) GetBuiltinActors() cid.Cid {
return cid.Undef
}
func (s *state4) SetBuiltinActors(c cid.Cid) error {
return xerrors.New("cannot set manifest cid before v8")
}

View File

@ -2,6 +2,7 @@ package system
import (
"github.com/ipfs/go-cid"
"golang.org/x/xerrors"
system5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/system"
@ -39,3 +40,9 @@ func (s *state5) GetBuiltinActors() cid.Cid {
return cid.Undef
}
func (s *state5) SetBuiltinActors(c cid.Cid) error {
return xerrors.New("cannot set manifest cid before v8")
}

View File

@ -2,6 +2,7 @@ package system
import (
"github.com/ipfs/go-cid"
"golang.org/x/xerrors"
system6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/system"
@ -39,3 +40,9 @@ func (s *state6) GetBuiltinActors() cid.Cid {
return cid.Undef
}
func (s *state6) SetBuiltinActors(c cid.Cid) error {
return xerrors.New("cannot set manifest cid before v8")
}

View File

@ -2,6 +2,7 @@ package system
import (
"github.com/ipfs/go-cid"
"golang.org/x/xerrors"
system7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/system"
@ -39,3 +40,9 @@ func (s *state7) GetBuiltinActors() cid.Cid {
return cid.Undef
}
func (s *state7) SetBuiltinActors(c cid.Cid) error {
return xerrors.New("cannot set manifest cid before v8")
}

View File

@ -41,3 +41,10 @@ func (s *state8) GetBuiltinActors() cid.Cid {
return s.State.BuiltinActors
}
func (s *state8) SetBuiltinActors(c cid.Cid) error {
s.State.BuiltinActors = c
return nil
}

Some files were not shown because too many files have changed in this diff Show More