Merge pull request #8941 from filecoin-project/gstuart/actors-cids-older-versions
Feat: api: Api call to get actor cids works for versions < 16
This commit is contained in:
commit
3bb7e9d113
328
chain/actors/actor_cids.go
Normal file
328
chain/actors/actor_cids.go
Normal file
@ -0,0 +1,328 @@
|
||||
package actors
|
||||
|
||||
import (
|
||||
"github.com/ipfs/go-cid"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"
|
||||
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"
|
||||
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"
|
||||
)
|
||||
|
||||
// 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) {
|
||||
|
||||
// Actors V8 and above
|
||||
if av >= Version8 {
|
||||
if cids, ok := GetActorCodeIDsFromManifest(av); ok {
|
||||
c, ok := cids[name]
|
||||
return c, ok
|
||||
}
|
||||
}
|
||||
|
||||
// Actors V7 and lower
|
||||
switch name {
|
||||
|
||||
case AccountKey:
|
||||
switch av {
|
||||
|
||||
case Version0:
|
||||
return builtin0.AccountActorCodeID, true
|
||||
|
||||
case Version2:
|
||||
return builtin2.AccountActorCodeID, true
|
||||
|
||||
case Version3:
|
||||
return builtin3.AccountActorCodeID, true
|
||||
|
||||
case Version4:
|
||||
return builtin4.AccountActorCodeID, true
|
||||
|
||||
case Version5:
|
||||
return builtin5.AccountActorCodeID, true
|
||||
|
||||
case Version6:
|
||||
return builtin6.AccountActorCodeID, true
|
||||
|
||||
case Version7:
|
||||
return builtin7.AccountActorCodeID, true
|
||||
}
|
||||
|
||||
case CronKey:
|
||||
switch av {
|
||||
|
||||
case Version0:
|
||||
return builtin0.CronActorCodeID, true
|
||||
|
||||
case Version2:
|
||||
return builtin2.CronActorCodeID, true
|
||||
|
||||
case Version3:
|
||||
return builtin3.CronActorCodeID, true
|
||||
|
||||
case Version4:
|
||||
return builtin4.CronActorCodeID, true
|
||||
|
||||
case Version5:
|
||||
return builtin5.CronActorCodeID, true
|
||||
|
||||
case Version6:
|
||||
return builtin6.CronActorCodeID, true
|
||||
|
||||
case Version7:
|
||||
return builtin7.CronActorCodeID, true
|
||||
}
|
||||
|
||||
case InitKey:
|
||||
switch av {
|
||||
|
||||
case Version0:
|
||||
return builtin0.InitActorCodeID, true
|
||||
|
||||
case Version2:
|
||||
return builtin2.InitActorCodeID, true
|
||||
|
||||
case Version3:
|
||||
return builtin3.InitActorCodeID, true
|
||||
|
||||
case Version4:
|
||||
return builtin4.InitActorCodeID, true
|
||||
|
||||
case Version5:
|
||||
return builtin5.InitActorCodeID, true
|
||||
|
||||
case Version6:
|
||||
return builtin6.InitActorCodeID, true
|
||||
|
||||
case Version7:
|
||||
return builtin7.InitActorCodeID, true
|
||||
}
|
||||
|
||||
case MarketKey:
|
||||
switch av {
|
||||
|
||||
case Version0:
|
||||
return builtin0.StorageMarketActorCodeID, true
|
||||
|
||||
case Version2:
|
||||
return builtin2.StorageMarketActorCodeID, true
|
||||
|
||||
case Version3:
|
||||
return builtin3.StorageMarketActorCodeID, true
|
||||
|
||||
case Version4:
|
||||
return builtin4.StorageMarketActorCodeID, true
|
||||
|
||||
case Version5:
|
||||
return builtin5.StorageMarketActorCodeID, true
|
||||
|
||||
case Version6:
|
||||
return builtin6.StorageMarketActorCodeID, true
|
||||
|
||||
case Version7:
|
||||
return builtin7.StorageMarketActorCodeID, true
|
||||
}
|
||||
|
||||
case MinerKey:
|
||||
switch av {
|
||||
|
||||
case Version0:
|
||||
return builtin0.StorageMinerActorCodeID, true
|
||||
|
||||
case Version2:
|
||||
return builtin2.StorageMinerActorCodeID, true
|
||||
|
||||
case Version3:
|
||||
return builtin3.StorageMinerActorCodeID, true
|
||||
|
||||
case Version4:
|
||||
return builtin4.StorageMinerActorCodeID, true
|
||||
|
||||
case Version5:
|
||||
return builtin5.StorageMinerActorCodeID, true
|
||||
|
||||
case Version6:
|
||||
return builtin6.StorageMinerActorCodeID, true
|
||||
|
||||
case Version7:
|
||||
return builtin7.StorageMinerActorCodeID, true
|
||||
}
|
||||
|
||||
case MultisigKey:
|
||||
switch av {
|
||||
|
||||
case Version0:
|
||||
return builtin0.MultisigActorCodeID, true
|
||||
|
||||
case Version2:
|
||||
return builtin2.MultisigActorCodeID, true
|
||||
|
||||
case Version3:
|
||||
return builtin3.MultisigActorCodeID, true
|
||||
|
||||
case Version4:
|
||||
return builtin4.MultisigActorCodeID, true
|
||||
|
||||
case Version5:
|
||||
return builtin5.MultisigActorCodeID, true
|
||||
|
||||
case Version6:
|
||||
return builtin6.MultisigActorCodeID, true
|
||||
|
||||
case Version7:
|
||||
return builtin7.MultisigActorCodeID, true
|
||||
}
|
||||
|
||||
case PaychKey:
|
||||
switch av {
|
||||
|
||||
case Version0:
|
||||
return builtin0.PaymentChannelActorCodeID, true
|
||||
|
||||
case Version2:
|
||||
return builtin2.PaymentChannelActorCodeID, true
|
||||
|
||||
case Version3:
|
||||
return builtin3.PaymentChannelActorCodeID, true
|
||||
|
||||
case Version4:
|
||||
return builtin4.PaymentChannelActorCodeID, true
|
||||
|
||||
case Version5:
|
||||
return builtin5.PaymentChannelActorCodeID, true
|
||||
|
||||
case Version6:
|
||||
return builtin6.PaymentChannelActorCodeID, true
|
||||
|
||||
case Version7:
|
||||
return builtin7.PaymentChannelActorCodeID, true
|
||||
}
|
||||
|
||||
case PowerKey:
|
||||
switch av {
|
||||
|
||||
case Version0:
|
||||
return builtin0.StoragePowerActorCodeID, true
|
||||
|
||||
case Version2:
|
||||
return builtin2.StoragePowerActorCodeID, true
|
||||
|
||||
case Version3:
|
||||
return builtin3.StoragePowerActorCodeID, true
|
||||
|
||||
case Version4:
|
||||
return builtin4.StoragePowerActorCodeID, true
|
||||
|
||||
case Version5:
|
||||
return builtin5.StoragePowerActorCodeID, true
|
||||
|
||||
case Version6:
|
||||
return builtin6.StoragePowerActorCodeID, true
|
||||
|
||||
case Version7:
|
||||
return builtin7.StoragePowerActorCodeID, true
|
||||
}
|
||||
|
||||
case RewardKey:
|
||||
switch av {
|
||||
|
||||
case Version0:
|
||||
return builtin0.RewardActorCodeID, true
|
||||
|
||||
case Version2:
|
||||
return builtin2.RewardActorCodeID, true
|
||||
|
||||
case Version3:
|
||||
return builtin3.RewardActorCodeID, true
|
||||
|
||||
case Version4:
|
||||
return builtin4.RewardActorCodeID, true
|
||||
|
||||
case Version5:
|
||||
return builtin5.RewardActorCodeID, true
|
||||
|
||||
case Version6:
|
||||
return builtin6.RewardActorCodeID, true
|
||||
|
||||
case Version7:
|
||||
return builtin7.RewardActorCodeID, true
|
||||
}
|
||||
|
||||
case SystemKey:
|
||||
switch av {
|
||||
|
||||
case Version0:
|
||||
return builtin0.SystemActorCodeID, true
|
||||
|
||||
case Version2:
|
||||
return builtin2.SystemActorCodeID, true
|
||||
|
||||
case Version3:
|
||||
return builtin3.SystemActorCodeID, true
|
||||
|
||||
case Version4:
|
||||
return builtin4.SystemActorCodeID, true
|
||||
|
||||
case Version5:
|
||||
return builtin5.SystemActorCodeID, true
|
||||
|
||||
case Version6:
|
||||
return builtin6.SystemActorCodeID, true
|
||||
|
||||
case Version7:
|
||||
return builtin7.SystemActorCodeID, true
|
||||
}
|
||||
|
||||
case VerifregKey:
|
||||
switch av {
|
||||
|
||||
case Version0:
|
||||
return builtin0.VerifiedRegistryActorCodeID, true
|
||||
|
||||
case Version2:
|
||||
return builtin2.VerifiedRegistryActorCodeID, true
|
||||
|
||||
case Version3:
|
||||
return builtin3.VerifiedRegistryActorCodeID, true
|
||||
|
||||
case Version4:
|
||||
return builtin4.VerifiedRegistryActorCodeID, true
|
||||
|
||||
case Version5:
|
||||
return builtin5.VerifiedRegistryActorCodeID, true
|
||||
|
||||
case Version6:
|
||||
return builtin6.VerifiedRegistryActorCodeID, true
|
||||
|
||||
case Version7:
|
||||
return builtin7.VerifiedRegistryActorCodeID, true
|
||||
}
|
||||
}
|
||||
|
||||
return cid.Undef, false
|
||||
}
|
||||
|
||||
// GetActorCodeIDs looks up all builtin actor's code CIDs by actor version.
|
||||
func GetActorCodeIDs(av Version) (map[string]cid.Cid, error) {
|
||||
cids, ok := GetActorCodeIDsFromManifest(av)
|
||||
if ok {
|
||||
return cids, nil
|
||||
}
|
||||
|
||||
actorsKeys := GetBuiltinActorsKeys()
|
||||
synthCids := make(map[string]cid.Cid)
|
||||
|
||||
for _, key := range actorsKeys {
|
||||
c, ok := GetActorCodeID(av, key)
|
||||
if !ok {
|
||||
return nil, xerrors.Errorf("could not find builtin actor cids for Actors version %d", av)
|
||||
}
|
||||
synthCids[key] = c
|
||||
}
|
||||
|
||||
return synthCids, nil
|
||||
}
|
@ -4,7 +4,6 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
@ -130,39 +129,6 @@ func IsBuiltinActor(c cid.Cid) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func GetAccountActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, actors.AccountKey); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
return builtin0.AccountActorCodeID, nil
|
||||
|
||||
case actors.Version2:
|
||||
return builtin2.AccountActorCodeID, nil
|
||||
|
||||
case actors.Version3:
|
||||
return builtin3.AccountActorCodeID, nil
|
||||
|
||||
case actors.Version4:
|
||||
return builtin4.AccountActorCodeID, nil
|
||||
|
||||
case actors.Version5:
|
||||
return builtin5.AccountActorCodeID, nil
|
||||
|
||||
case actors.Version6:
|
||||
return builtin6.AccountActorCodeID, nil
|
||||
|
||||
case actors.Version7:
|
||||
return builtin7.AccountActorCodeID, nil
|
||||
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func IsAccountActor(c cid.Cid) bool {
|
||||
name, _, ok := actors.GetActorMetaByCode(c)
|
||||
if ok {
|
||||
@ -200,138 +166,6 @@ func IsAccountActor(c cid.Cid) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func GetCronActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, actors.CronKey); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
return builtin0.CronActorCodeID, nil
|
||||
|
||||
case actors.Version2:
|
||||
return builtin2.CronActorCodeID, nil
|
||||
|
||||
case actors.Version3:
|
||||
return builtin3.CronActorCodeID, nil
|
||||
|
||||
case actors.Version4:
|
||||
return builtin4.CronActorCodeID, nil
|
||||
|
||||
case actors.Version5:
|
||||
return builtin5.CronActorCodeID, nil
|
||||
|
||||
case actors.Version6:
|
||||
return builtin6.CronActorCodeID, nil
|
||||
|
||||
case actors.Version7:
|
||||
return builtin7.CronActorCodeID, nil
|
||||
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func GetInitActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, actors.InitKey); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
return builtin0.InitActorCodeID, nil
|
||||
|
||||
case actors.Version2:
|
||||
return builtin2.InitActorCodeID, nil
|
||||
|
||||
case actors.Version3:
|
||||
return builtin3.InitActorCodeID, nil
|
||||
|
||||
case actors.Version4:
|
||||
return builtin4.InitActorCodeID, nil
|
||||
|
||||
case actors.Version5:
|
||||
return builtin5.InitActorCodeID, nil
|
||||
|
||||
case actors.Version6:
|
||||
return builtin6.InitActorCodeID, nil
|
||||
|
||||
case actors.Version7:
|
||||
return builtin7.InitActorCodeID, nil
|
||||
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func GetMarketActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, actors.MarketKey); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
return builtin0.StorageMarketActorCodeID, nil
|
||||
|
||||
case actors.Version2:
|
||||
return builtin2.StorageMarketActorCodeID, nil
|
||||
|
||||
case actors.Version3:
|
||||
return builtin3.StorageMarketActorCodeID, nil
|
||||
|
||||
case actors.Version4:
|
||||
return builtin4.StorageMarketActorCodeID, nil
|
||||
|
||||
case actors.Version5:
|
||||
return builtin5.StorageMarketActorCodeID, nil
|
||||
|
||||
case actors.Version6:
|
||||
return builtin6.StorageMarketActorCodeID, nil
|
||||
|
||||
case actors.Version7:
|
||||
return builtin7.StorageMarketActorCodeID, nil
|
||||
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func GetMinerActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, actors.MinerKey); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
return builtin0.StorageMinerActorCodeID, nil
|
||||
|
||||
case actors.Version2:
|
||||
return builtin2.StorageMinerActorCodeID, nil
|
||||
|
||||
case actors.Version3:
|
||||
return builtin3.StorageMinerActorCodeID, nil
|
||||
|
||||
case actors.Version4:
|
||||
return builtin4.StorageMinerActorCodeID, nil
|
||||
|
||||
case actors.Version5:
|
||||
return builtin5.StorageMinerActorCodeID, nil
|
||||
|
||||
case actors.Version6:
|
||||
return builtin6.StorageMinerActorCodeID, nil
|
||||
|
||||
case actors.Version7:
|
||||
return builtin7.StorageMinerActorCodeID, nil
|
||||
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func IsStorageMinerActor(c cid.Cid) bool {
|
||||
name, _, ok := actors.GetActorMetaByCode(c)
|
||||
if ok {
|
||||
@ -369,39 +203,6 @@ func IsStorageMinerActor(c cid.Cid) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func GetMultisigActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, actors.MultisigKey); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
return builtin0.MultisigActorCodeID, nil
|
||||
|
||||
case actors.Version2:
|
||||
return builtin2.MultisigActorCodeID, nil
|
||||
|
||||
case actors.Version3:
|
||||
return builtin3.MultisigActorCodeID, nil
|
||||
|
||||
case actors.Version4:
|
||||
return builtin4.MultisigActorCodeID, nil
|
||||
|
||||
case actors.Version5:
|
||||
return builtin5.MultisigActorCodeID, nil
|
||||
|
||||
case actors.Version6:
|
||||
return builtin6.MultisigActorCodeID, nil
|
||||
|
||||
case actors.Version7:
|
||||
return builtin7.MultisigActorCodeID, nil
|
||||
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func IsMultisigActor(c cid.Cid) bool {
|
||||
name, _, ok := actors.GetActorMetaByCode(c)
|
||||
if ok {
|
||||
@ -439,39 +240,6 @@ func IsMultisigActor(c cid.Cid) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func GetPaymentChannelActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, actors.PaychKey); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
return builtin0.PaymentChannelActorCodeID, nil
|
||||
|
||||
case actors.Version2:
|
||||
return builtin2.PaymentChannelActorCodeID, nil
|
||||
|
||||
case actors.Version3:
|
||||
return builtin3.PaymentChannelActorCodeID, nil
|
||||
|
||||
case actors.Version4:
|
||||
return builtin4.PaymentChannelActorCodeID, nil
|
||||
|
||||
case actors.Version5:
|
||||
return builtin5.PaymentChannelActorCodeID, nil
|
||||
|
||||
case actors.Version6:
|
||||
return builtin6.PaymentChannelActorCodeID, nil
|
||||
|
||||
case actors.Version7:
|
||||
return builtin7.PaymentChannelActorCodeID, nil
|
||||
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func IsPaymentChannelActor(c cid.Cid) bool {
|
||||
name, _, ok := actors.GetActorMetaByCode(c)
|
||||
if ok {
|
||||
@ -509,138 +277,6 @@ func IsPaymentChannelActor(c cid.Cid) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func GetPowerActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, actors.PowerKey); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
return builtin0.StoragePowerActorCodeID, nil
|
||||
|
||||
case actors.Version2:
|
||||
return builtin2.StoragePowerActorCodeID, nil
|
||||
|
||||
case actors.Version3:
|
||||
return builtin3.StoragePowerActorCodeID, nil
|
||||
|
||||
case actors.Version4:
|
||||
return builtin4.StoragePowerActorCodeID, nil
|
||||
|
||||
case actors.Version5:
|
||||
return builtin5.StoragePowerActorCodeID, nil
|
||||
|
||||
case actors.Version6:
|
||||
return builtin6.StoragePowerActorCodeID, nil
|
||||
|
||||
case actors.Version7:
|
||||
return builtin7.StoragePowerActorCodeID, nil
|
||||
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func GetRewardActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, actors.RewardKey); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
return builtin0.RewardActorCodeID, nil
|
||||
|
||||
case actors.Version2:
|
||||
return builtin2.RewardActorCodeID, nil
|
||||
|
||||
case actors.Version3:
|
||||
return builtin3.RewardActorCodeID, nil
|
||||
|
||||
case actors.Version4:
|
||||
return builtin4.RewardActorCodeID, nil
|
||||
|
||||
case actors.Version5:
|
||||
return builtin5.RewardActorCodeID, nil
|
||||
|
||||
case actors.Version6:
|
||||
return builtin6.RewardActorCodeID, nil
|
||||
|
||||
case actors.Version7:
|
||||
return builtin7.RewardActorCodeID, nil
|
||||
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func GetSystemActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, actors.SystemKey); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
return builtin0.SystemActorCodeID, nil
|
||||
|
||||
case actors.Version2:
|
||||
return builtin2.SystemActorCodeID, nil
|
||||
|
||||
case actors.Version3:
|
||||
return builtin3.SystemActorCodeID, nil
|
||||
|
||||
case actors.Version4:
|
||||
return builtin4.SystemActorCodeID, nil
|
||||
|
||||
case actors.Version5:
|
||||
return builtin5.SystemActorCodeID, nil
|
||||
|
||||
case actors.Version6:
|
||||
return builtin6.SystemActorCodeID, nil
|
||||
|
||||
case actors.Version7:
|
||||
return builtin7.SystemActorCodeID, nil
|
||||
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func GetVerifregActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, actors.VerifregKey); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
return builtin0.VerifiedRegistryActorCodeID, nil
|
||||
|
||||
case actors.Version2:
|
||||
return builtin2.VerifiedRegistryActorCodeID, nil
|
||||
|
||||
case actors.Version3:
|
||||
return builtin3.VerifiedRegistryActorCodeID, nil
|
||||
|
||||
case actors.Version4:
|
||||
return builtin4.VerifiedRegistryActorCodeID, nil
|
||||
|
||||
case actors.Version5:
|
||||
return builtin5.VerifiedRegistryActorCodeID, nil
|
||||
|
||||
case actors.Version6:
|
||||
return builtin6.VerifiedRegistryActorCodeID, nil
|
||||
|
||||
case actors.Version7:
|
||||
return builtin7.VerifiedRegistryActorCodeID, nil
|
||||
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func makeAddress(addr string) address.Address {
|
||||
ret, err := address.NewFromString(addr)
|
||||
if err != nil {
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/ipfs/go-cid"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
{{range .versions}}
|
||||
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
|
||||
@ -85,23 +84,6 @@ func IsBuiltinActor(c cid.Cid) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func GetAccountActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, actors.AccountKey); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
{{if (le . 7)}}
|
||||
case actors.Version{{.}}:
|
||||
return builtin{{.}}.AccountActorCodeID, nil
|
||||
{{end}}
|
||||
{{end}}
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func IsAccountActor(c cid.Cid) bool {
|
||||
name, _, ok := actors.GetActorMetaByCode(c)
|
||||
if ok {
|
||||
@ -118,74 +100,6 @@ func IsAccountActor(c cid.Cid) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func GetCronActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, actors.CronKey); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
{{if (le . 7)}}
|
||||
case actors.Version{{.}}:
|
||||
return builtin{{.}}.CronActorCodeID, nil
|
||||
{{end}}
|
||||
{{end}}
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func GetInitActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, actors.InitKey); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
{{if (le . 7)}}
|
||||
case actors.Version{{.}}:
|
||||
return builtin{{.}}.InitActorCodeID, nil
|
||||
{{end}}
|
||||
{{end}}
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func GetMarketActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, actors.MarketKey); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
{{if (le . 7)}}
|
||||
case actors.Version{{.}}:
|
||||
return builtin{{.}}.StorageMarketActorCodeID, nil
|
||||
{{end}}
|
||||
{{end}}
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func GetMinerActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, actors.MinerKey); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
{{if (le . 7)}}
|
||||
case actors.Version{{.}}:
|
||||
return builtin{{.}}.StorageMinerActorCodeID, nil
|
||||
{{end}}
|
||||
{{end}}
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func IsStorageMinerActor(c cid.Cid) bool {
|
||||
name, _, ok := actors.GetActorMetaByCode(c)
|
||||
if ok {
|
||||
@ -202,23 +116,6 @@ func IsStorageMinerActor(c cid.Cid) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func GetMultisigActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, actors.MultisigKey); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
{{if (le . 7)}}
|
||||
case actors.Version{{.}}:
|
||||
return builtin{{.}}.MultisigActorCodeID, nil
|
||||
{{end}}
|
||||
{{end}}
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func IsMultisigActor(c cid.Cid) bool {
|
||||
name, _, ok := actors.GetActorMetaByCode(c)
|
||||
if ok {
|
||||
@ -235,23 +132,6 @@ func IsMultisigActor(c cid.Cid) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func GetPaymentChannelActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, actors.PaychKey); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
{{if (le . 7)}}
|
||||
case actors.Version{{.}}:
|
||||
return builtin{{.}}.PaymentChannelActorCodeID, nil
|
||||
{{end}}
|
||||
{{end}}
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func IsPaymentChannelActor(c cid.Cid) bool {
|
||||
name, _, ok := actors.GetActorMetaByCode(c)
|
||||
if ok {
|
||||
@ -268,74 +148,6 @@ func IsPaymentChannelActor(c cid.Cid) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func GetPowerActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, actors.PowerKey); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
{{if (le . 7)}}
|
||||
case actors.Version{{.}}:
|
||||
return builtin{{.}}.StoragePowerActorCodeID, nil
|
||||
{{end}}
|
||||
{{end}}
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func GetRewardActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, actors.RewardKey); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
{{if (le . 7)}}
|
||||
case actors.Version{{.}}:
|
||||
return builtin{{.}}.RewardActorCodeID, nil
|
||||
{{end}}
|
||||
{{end}}
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func GetSystemActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, actors.SystemKey); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
{{if (le . 7)}}
|
||||
case actors.Version{{.}}:
|
||||
return builtin{{.}}.SystemActorCodeID, nil
|
||||
{{end}}
|
||||
{{end}}
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func GetVerifregActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, actors.VerifregKey); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
{{if (le . 7)}}
|
||||
case actors.Version{{.}}:
|
||||
return builtin{{.}}.VerifiedRegistryActorCodeID, nil
|
||||
{{end}}
|
||||
{{end}}
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func makeAddress(addr string) address.Address {
|
||||
ret, err := address.NewFromString(addr)
|
||||
if err != nil {
|
||||
|
@ -14,7 +14,6 @@ import (
|
||||
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"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
{{end}}
|
||||
|
||||
|
||||
@ -69,8 +68,8 @@ func (m message{{.v}}) Create(
|
||||
ConstructorParams: enc,
|
||||
}
|
||||
{{else}}
|
||||
code, err := builtin.GetMultisigActorCodeID(actors.Version{{.v}})
|
||||
if err != nil {
|
||||
code, ok := actors.GetActorCodeID(actors.Version{{.v}}, actors.MultisigKey)
|
||||
if !ok {
|
||||
return nil, xerrors.Errorf("failed to get multisig code ID")
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
multisig8 "github.com/filecoin-project/go-state-types/builtin/v8/multisig"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
)
|
||||
@ -50,8 +49,8 @@ func (m message8) Create(
|
||||
return nil, actErr
|
||||
}
|
||||
|
||||
code, err := builtin.GetMultisigActorCodeID(actors.Version8)
|
||||
if err != nil {
|
||||
code, ok := actors.GetActorCodeID(actors.Version8, actors.MultisigKey)
|
||||
if !ok {
|
||||
return nil, xerrors.Errorf("failed to get multisig code ID")
|
||||
}
|
||||
|
||||
|
@ -113,6 +113,15 @@ func ReadManifest(ctx context.Context, store cbor.IpldStore, mfCid cid.Cid) (map
|
||||
return metadata, nil
|
||||
}
|
||||
|
||||
// GetActorCodeIDsFromManifest looks up all builtin actor's code CIDs by actor version for versions that have a manifest.
|
||||
func GetActorCodeIDsFromManifest(av Version) (map[string]cid.Cid, bool) {
|
||||
manifestMx.RLock()
|
||||
defer manifestMx.RUnlock()
|
||||
|
||||
cids, ok := manifests[av]
|
||||
return cids, ok
|
||||
}
|
||||
|
||||
// Given a Manifest CID, get the manifest from the store and Load data into its entries
|
||||
func LoadManifest(ctx context.Context, mfCid cid.Cid, adtStore adt.Store) (*manifest.Manifest, error) {
|
||||
var mf manifest.Manifest
|
||||
@ -128,15 +137,6 @@ func LoadManifest(ctx context.Context, mfCid cid.Cid, adtStore adt.Store) (*mani
|
||||
return &mf, nil
|
||||
}
|
||||
|
||||
// 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) {
|
||||
manifestMx.RLock()
|
||||
defer manifestMx.RUnlock()
|
||||
|
||||
c, ok := manifests[av][name]
|
||||
return c, ok
|
||||
}
|
||||
|
||||
func GetActorMetaByCode(c cid.Cid) (string, Version, bool) {
|
||||
manifestMx.RLock()
|
||||
defer manifestMx.RUnlock()
|
||||
|
@ -14,7 +14,6 @@ import (
|
||||
bstore "github.com/filecoin-project/lotus/blockstore"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/system"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
)
|
||||
@ -48,9 +47,9 @@ func SetupSystemActor(ctx context.Context, bs bstore.Blockstore, av actors.Versi
|
||||
return nil, err
|
||||
}
|
||||
|
||||
actcid, err := builtin.GetSystemActorCodeID(av)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
actcid, ok := actors.GetActorCodeID(av, actors.SystemKey)
|
||||
if !ok {
|
||||
return nil, xerrors.Errorf("failed to get system actor code ID for actors version %d", av)
|
||||
}
|
||||
|
||||
act := &types.Actor{
|
||||
|
@ -16,7 +16,6 @@ import (
|
||||
|
||||
bstore "github.com/filecoin-project/lotus/blockstore"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/genesis"
|
||||
@ -174,9 +173,9 @@ func SetupInitActor(ctx context.Context, bs bstore.Blockstore, netname string, i
|
||||
return 0, nil, nil, err
|
||||
}
|
||||
|
||||
actcid, err := builtin.GetInitActorCodeID(av)
|
||||
if err != nil {
|
||||
return 0, nil, nil, err
|
||||
actcid, ok := actors.GetActorCodeID(av, actors.InitKey)
|
||||
if !ok {
|
||||
return 0, nil, nil, xerrors.Errorf("failed to get init actor code ID for actors version %d", av)
|
||||
}
|
||||
|
||||
act := &types.Actor{
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
|
||||
cbor "github.com/ipfs/go-ipld-cbor"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
|
||||
@ -11,7 +12,6 @@ import (
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/reward"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
)
|
||||
@ -28,9 +28,9 @@ func SetupRewardActor(ctx context.Context, bs bstore.Blockstore, qaPower big.Int
|
||||
return nil, err
|
||||
}
|
||||
|
||||
actcid, err := builtin.GetRewardActorCodeID(av)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
actcid, ok := actors.GetActorCodeID(av, actors.RewardKey)
|
||||
if !ok {
|
||||
return nil, xerrors.Errorf("failed to get reward actor code ID for actors version %d", av)
|
||||
}
|
||||
|
||||
act := &types.Actor{
|
||||
|
@ -4,13 +4,13 @@ import (
|
||||
"context"
|
||||
|
||||
cbor "github.com/ipfs/go-ipld-cbor"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
|
||||
bstore "github.com/filecoin-project/lotus/blockstore"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/cron"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
)
|
||||
@ -27,9 +27,9 @@ func SetupCronActor(ctx context.Context, bs bstore.Blockstore, av actors.Version
|
||||
return nil, err
|
||||
}
|
||||
|
||||
actcid, err := builtin.GetCronActorCodeID(av)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
actcid, ok := actors.GetActorCodeID(av, actors.CronKey)
|
||||
if !ok {
|
||||
return nil, xerrors.Errorf("failed to get cron actor code ID for actors version %d", av)
|
||||
}
|
||||
|
||||
act := &types.Actor{
|
||||
|
@ -4,13 +4,13 @@ import (
|
||||
"context"
|
||||
|
||||
cbor "github.com/ipfs/go-ipld-cbor"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||
|
||||
bstore "github.com/filecoin-project/lotus/blockstore"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/power"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
)
|
||||
@ -28,9 +28,9 @@ func SetupStoragePowerActor(ctx context.Context, bs bstore.Blockstore, av actors
|
||||
return nil, err
|
||||
}
|
||||
|
||||
actcid, err := builtin.GetPowerActorCodeID(av)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
actcid, ok := actors.GetActorCodeID(av, actors.PowerKey)
|
||||
if !ok {
|
||||
return nil, xerrors.Errorf("failed to get power actor code ID for actors version %d", av)
|
||||
}
|
||||
|
||||
act := &types.Actor{
|
||||
|
@ -4,13 +4,13 @@ import (
|
||||
"context"
|
||||
|
||||
cbor "github.com/ipfs/go-ipld-cbor"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
|
||||
bstore "github.com/filecoin-project/lotus/blockstore"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/market"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
)
|
||||
@ -27,9 +27,9 @@ func SetupStorageMarketActor(ctx context.Context, bs bstore.Blockstore, av actor
|
||||
return nil, err
|
||||
}
|
||||
|
||||
actcid, err := builtin.GetMarketActorCodeID(av)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
actcid, ok := actors.GetActorCodeID(av, actors.MarketKey)
|
||||
if !ok {
|
||||
return nil, xerrors.Errorf("failed to get market actor code ID for actors version %d", av)
|
||||
}
|
||||
|
||||
act := &types.Actor{
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
|
||||
cbor "github.com/ipfs/go-ipld-cbor"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
@ -11,7 +12,6 @@ import (
|
||||
|
||||
bstore "github.com/filecoin-project/lotus/blockstore"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/verifreg"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
)
|
||||
@ -40,9 +40,9 @@ func SetupVerifiedRegistryActor(ctx context.Context, bs bstore.Blockstore, av ac
|
||||
return nil, err
|
||||
}
|
||||
|
||||
actcid, err := builtin.GetVerifregActorCodeID(av)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
actcid, ok := actors.GetActorCodeID(av, actors.VerifregKey)
|
||||
if !ok {
|
||||
return nil, xerrors.Errorf("failed to get verifreg actor code ID for actors version %d", av)
|
||||
}
|
||||
|
||||
act := &types.Actor{
|
||||
|
@ -367,9 +367,9 @@ func MakeAccountActor(ctx context.Context, cst cbor.IpldStore, av actors.Version
|
||||
return nil, err
|
||||
}
|
||||
|
||||
actcid, err := builtin.GetAccountActorCodeID(av)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
actcid, ok := actors.GetActorCodeID(av, actors.AccountKey)
|
||||
if !ok {
|
||||
return nil, xerrors.Errorf("failed to get account actor code ID for actors version %d", av)
|
||||
}
|
||||
|
||||
act := &types.Actor{
|
||||
@ -449,9 +449,9 @@ func CreateMultisigAccount(ctx context.Context, cst cbor.IpldStore, state *state
|
||||
return err
|
||||
}
|
||||
|
||||
actcid, err := builtin.GetMultisigActorCodeID(av)
|
||||
if err != nil {
|
||||
return err
|
||||
actcid, ok := actors.GetActorCodeID(av, actors.MultisigKey)
|
||||
if !ok {
|
||||
return xerrors.Errorf("failed to get multisig code ID for actors version %d", av)
|
||||
}
|
||||
|
||||
err = state.SetActor(ida, &types.Actor{
|
||||
|
19
cli/state.go
19
cli/state.go
@ -1900,19 +1900,7 @@ var StateSysActorCIDsCmd = &cli.Command{
|
||||
|
||||
ctx := ReqContext(cctx)
|
||||
|
||||
ts, err := LoadTipSet(ctx, cctx, api)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
nv, err := api.StateNetworkVersion(ctx, ts.Key())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if cctx.IsSet("network-version") {
|
||||
nv = network.Version(cctx.Uint64("network-version"))
|
||||
}
|
||||
nv := network.Version(cctx.Uint64("network-version"))
|
||||
|
||||
fmt.Printf("Network Version: %d\n", nv)
|
||||
|
||||
@ -1922,6 +1910,11 @@ var StateSysActorCIDsCmd = &cli.Command{
|
||||
}
|
||||
fmt.Printf("Actor Version: %d\n", actorVersion)
|
||||
|
||||
manifestCid, ok := actors.GetManifest(actorVersion)
|
||||
if ok {
|
||||
fmt.Printf("Manifest CID: %v\n", manifestCid)
|
||||
}
|
||||
|
||||
tw := tabwriter.NewWriter(os.Stdout, 2, 4, 2, ' ', 0)
|
||||
_, _ = fmt.Fprintln(tw, "\nActor\tCID\t")
|
||||
|
||||
|
@ -1526,27 +1526,14 @@ func (m *StateModule) StateNetworkVersion(ctx context.Context, tsk types.TipSetK
|
||||
func (a *StateAPI) StateActorCodeCIDs(ctx context.Context, nv network.Version) (map[string]cid.Cid, error) {
|
||||
actorVersion, err := actors.VersionForNetwork(nv)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("invalid network version")
|
||||
return nil, xerrors.Errorf("invalid network version %d: %w", nv, err)
|
||||
}
|
||||
|
||||
cids := make(map[string]cid.Cid)
|
||||
|
||||
manifestCid, ok := actors.GetManifest(actorVersion)
|
||||
if !ok {
|
||||
return nil, xerrors.Errorf("cannot get manifest CID")
|
||||
cids, err := actors.GetActorCodeIDs(actorVersion)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("could not find cids for network version %d, actors version %d: %w", nv, actorVersion, err)
|
||||
}
|
||||
|
||||
cids["_manifest"] = manifestCid
|
||||
|
||||
var actorKeys = actors.GetBuiltinActorsKeys()
|
||||
for _, name := range actorKeys {
|
||||
actorCID, ok := actors.GetActorCodeID(actorVersion, name)
|
||||
if !ok {
|
||||
return nil, xerrors.Errorf("didn't find actor %v code id for actor version %d", name,
|
||||
actorVersion)
|
||||
}
|
||||
cids[name] = actorCID
|
||||
}
|
||||
return cids, nil
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,6 @@ import (
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
lbuiltin "github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
"github.com/filecoin-project/lotus/chain/actors/policy"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/journal"
|
||||
@ -309,9 +308,9 @@ func (m *mockStorageMinerAPI) StateMinerProvingDeadline(ctx context.Context, add
|
||||
}
|
||||
|
||||
func (m *mockStorageMinerAPI) StateGetActor(ctx context.Context, actor address.Address, ts types.TipSetKey) (*types.Actor, error) {
|
||||
code, err := lbuiltin.GetMinerActorCodeID(actors.Version7)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
code, ok := actors.GetActorCodeID(actors.Version7, actors.MinerKey)
|
||||
if !ok {
|
||||
return nil, xerrors.Errorf("failed to get miner actor code ID for actors version %d", actors.Version7)
|
||||
}
|
||||
return &types.Actor{
|
||||
Code: code,
|
||||
|
Loading…
Reference in New Issue
Block a user