diff --git a/chain/actors/builtin/builtin.go b/chain/actors/builtin/builtin.go index d62fae46260..c1d6ad018b9 100644 --- a/chain/actors/builtin/builtin.go +++ b/chain/actors/builtin/builtin.go @@ -5,7 +5,6 @@ import ( "github.com/filecoin-project/go-address" "github.com/ipfs/go-cid" - "golang.org/x/xerrors" builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" @@ -139,39 +138,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 { @@ -209,138 +175,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 { @@ -378,39 +212,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 { @@ -448,39 +249,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 { @@ -518,138 +286,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 { diff --git a/chain/actors/builtin/builtin.go.template b/chain/actors/builtin/builtin.go.template index ef4dcef396e..d536eff36d8 100644 --- a/chain/actors/builtin/builtin.go.template +++ b/chain/actors/builtin/builtin.go.template @@ -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 { diff --git a/chain/actors/builtin/multisig/message.go.template b/chain/actors/builtin/multisig/message.go.template index 4db88826ad3..5542f4eecd9 100644 --- a/chain/actors/builtin/multisig/message.go.template +++ b/chain/actors/builtin/multisig/message.go.template @@ -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") } diff --git a/chain/actors/builtin/multisig/message8.go b/chain/actors/builtin/multisig/message8.go index bc560f50dab..18429fb5bb5 100644 --- a/chain/actors/builtin/multisig/message8.go +++ b/chain/actors/builtin/multisig/message8.go @@ -9,7 +9,6 @@ import ( builtin8 "github.com/filecoin-project/go-state-types/builtin" init8 "github.com/filecoin-project/go-state-types/builtin/v8/init" multisig8 "github.com/filecoin-project/go-state-types/builtin/v8/multisig" - "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/actors" init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init" @@ -51,8 +50,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") } diff --git a/chain/actors/manifest.go b/chain/actors/manifest.go index cab52226985..eb45c3bde33 100644 --- a/chain/actors/manifest.go +++ b/chain/actors/manifest.go @@ -113,7 +113,7 @@ func ReadManifest(ctx context.Context, store cbor.IpldStore, mfCid cid.Cid) (map return metadata, nil } -// GetActorCodeIDs looks up a builtin actor's code CID by actor version. +// 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() diff --git a/chain/gen/genesis/f00_system.go b/chain/gen/genesis/f00_system.go index 527701f1718..6a1a9cbd1e5 100644 --- a/chain/gen/genesis/f00_system.go +++ b/chain/gen/genesis/f00_system.go @@ -9,8 +9,6 @@ import ( "github.com/filecoin-project/go-state-types/manifest" - "github.com/filecoin-project/lotus/chain/actors/builtin" - "golang.org/x/xerrors" "github.com/filecoin-project/go-state-types/big" @@ -53,9 +51,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{ diff --git a/chain/gen/genesis/f01_init.go b/chain/gen/genesis/f01_init.go index f1df7ae2aae..53f4f367cc1 100644 --- a/chain/gen/genesis/f01_init.go +++ b/chain/gen/genesis/f01_init.go @@ -5,8 +5,6 @@ import ( "encoding/json" "fmt" - "github.com/filecoin-project/lotus/chain/actors/builtin" - init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init" "github.com/filecoin-project/lotus/chain/actors" @@ -178,9 +176,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{ diff --git a/chain/gen/genesis/f02_reward.go b/chain/gen/genesis/f02_reward.go index e4d6aa32a2e..ec0f68c2fc7 100644 --- a/chain/gen/genesis/f02_reward.go +++ b/chain/gen/genesis/f02_reward.go @@ -3,7 +3,7 @@ package genesis import ( "context" - "github.com/filecoin-project/lotus/chain/actors/builtin" + "golang.org/x/xerrors" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" @@ -30,9 +30,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{ diff --git a/chain/gen/genesis/f03_cron.go b/chain/gen/genesis/f03_cron.go index fad5e6fa639..b88f94e8c46 100644 --- a/chain/gen/genesis/f03_cron.go +++ b/chain/gen/genesis/f03_cron.go @@ -3,7 +3,7 @@ package genesis import ( "context" - "github.com/filecoin-project/lotus/chain/actors/builtin" + "golang.org/x/xerrors" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/lotus/chain/actors" @@ -28,9 +28,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{ diff --git a/chain/gen/genesis/f04_power.go b/chain/gen/genesis/f04_power.go index 35cd5f87bcb..1afcaa01221 100644 --- a/chain/gen/genesis/f04_power.go +++ b/chain/gen/genesis/f04_power.go @@ -3,7 +3,7 @@ package genesis import ( "context" - "github.com/filecoin-project/lotus/chain/actors/builtin" + "golang.org/x/xerrors" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/lotus/chain/actors/builtin/power" @@ -30,9 +30,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{ diff --git a/chain/gen/genesis/f05_market.go b/chain/gen/genesis/f05_market.go index 045842cdecd..dff8218aa62 100644 --- a/chain/gen/genesis/f05_market.go +++ b/chain/gen/genesis/f05_market.go @@ -3,7 +3,7 @@ package genesis import ( "context" - "github.com/filecoin-project/lotus/chain/actors/builtin" + "golang.org/x/xerrors" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/lotus/chain/actors" @@ -28,9 +28,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{ diff --git a/chain/gen/genesis/f06_vreg.go b/chain/gen/genesis/f06_vreg.go index d93b01a4fab..b60a9a59956 100644 --- a/chain/gen/genesis/f06_vreg.go +++ b/chain/gen/genesis/f06_vreg.go @@ -3,7 +3,7 @@ package genesis import ( "context" - "github.com/filecoin-project/lotus/chain/actors/builtin" + "golang.org/x/xerrors" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/lotus/chain/actors/builtin/verifreg" @@ -43,9 +43,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{ diff --git a/chain/gen/genesis/genesis.go b/chain/gen/genesis/genesis.go index 138437b78aa..a513fcff329 100644 --- a/chain/gen/genesis/genesis.go +++ b/chain/gen/genesis/genesis.go @@ -381,9 +381,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{ @@ -463,9 +463,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{ diff --git a/storage/wdpost_run_test.go b/storage/wdpost_run_test.go index 6efb3e54769..e173b65435b 100644 --- a/storage/wdpost_run_test.go +++ b/storage/wdpost_run_test.go @@ -9,7 +9,6 @@ import ( prooftypes "github.com/filecoin-project/go-state-types/proof" "github.com/filecoin-project/lotus/chain/actors" - lbuiltin "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/stretchr/testify/require" @@ -347,9 +346,9 @@ func (m *mockStorageMinerAPI) StateSearchMsg(ctx context.Context, from types.Tip } 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,