diff --git a/build/openrpc/full.json.gz b/build/openrpc/full.json.gz index 0e063bf5830..3b17bfc26f8 100644 Binary files a/build/openrpc/full.json.gz and b/build/openrpc/full.json.gz differ diff --git a/build/openrpc/gateway.json.gz b/build/openrpc/gateway.json.gz index f3ac74b04db..d2944f5d463 100644 Binary files a/build/openrpc/gateway.json.gz and b/build/openrpc/gateway.json.gz differ diff --git a/build/openrpc/miner.json.gz b/build/openrpc/miner.json.gz index 9f2e3fafc4f..5203888b087 100644 Binary files a/build/openrpc/miner.json.gz and b/build/openrpc/miner.json.gz differ diff --git a/build/openrpc/worker.json.gz b/build/openrpc/worker.json.gz index 9f3a8ff89ca..4a724cbe9cc 100644 Binary files a/build/openrpc/worker.json.gz and b/build/openrpc/worker.json.gz differ diff --git a/chain/actors/actor_cids.go b/chain/actors/actor_cids.go index ddcd360d534..71d844d5534 100644 --- a/chain/actors/actor_cids.go +++ b/chain/actors/actor_cids.go @@ -1,6 +1,9 @@ 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" @@ -8,8 +11,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" - "github.com/ipfs/go-cid" - "golang.org/x/xerrors" ) // GetActorCodeID looks up a builtin actor's code CID by actor version and canonical actor name. diff --git a/chain/actors/builtin/builtin.go b/chain/actors/builtin/builtin.go index 4c994c9aa2c..fb95a28d6c7 100644 --- a/chain/actors/builtin/builtin.go +++ b/chain/actors/builtin/builtin.go @@ -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 { 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 dacc5310855..23bee19d0f9 100644 --- a/chain/actors/builtin/multisig/message8.go +++ b/chain/actors/builtin/multisig/message8.go @@ -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") } diff --git a/chain/actors/manifest.go b/chain/actors/manifest.go index ca7159179d8..88598826a9e 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 82f70f19642..1cd50f5e11c 100644 --- a/chain/gen/genesis/f00_system.go +++ b/chain/gen/genesis/f00_system.go @@ -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{ diff --git a/chain/gen/genesis/f01_init.go b/chain/gen/genesis/f01_init.go index b020f5a5f42..ddb448de929 100644 --- a/chain/gen/genesis/f01_init.go +++ b/chain/gen/genesis/f01_init.go @@ -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{ diff --git a/chain/gen/genesis/f02_reward.go b/chain/gen/genesis/f02_reward.go index 2fd7709b621..0d0c1db0f28 100644 --- a/chain/gen/genesis/f02_reward.go +++ b/chain/gen/genesis/f02_reward.go @@ -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{ diff --git a/chain/gen/genesis/f03_cron.go b/chain/gen/genesis/f03_cron.go index 1b24ff7e936..c9fe7c11850 100644 --- a/chain/gen/genesis/f03_cron.go +++ b/chain/gen/genesis/f03_cron.go @@ -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{ diff --git a/chain/gen/genesis/f04_power.go b/chain/gen/genesis/f04_power.go index 7efa27733aa..20232c9b216 100644 --- a/chain/gen/genesis/f04_power.go +++ b/chain/gen/genesis/f04_power.go @@ -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{ diff --git a/chain/gen/genesis/f05_market.go b/chain/gen/genesis/f05_market.go index 880b027000b..9109e278488 100644 --- a/chain/gen/genesis/f05_market.go +++ b/chain/gen/genesis/f05_market.go @@ -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{ diff --git a/chain/gen/genesis/f06_vreg.go b/chain/gen/genesis/f06_vreg.go index 07e17577405..381a115d4c0 100644 --- a/chain/gen/genesis/f06_vreg.go +++ b/chain/gen/genesis/f06_vreg.go @@ -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{ diff --git a/chain/gen/genesis/genesis.go b/chain/gen/genesis/genesis.go index 6304fb7f8e4..1e2b3022c9e 100644 --- a/chain/gen/genesis/genesis.go +++ b/chain/gen/genesis/genesis.go @@ -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{ diff --git a/storage/wdpost/wdpost_run_test.go b/storage/wdpost/wdpost_run_test.go index a7846b32b67..9a11933fbfe 100644 --- a/storage/wdpost/wdpost_run_test.go +++ b/storage/wdpost/wdpost_run_test.go @@ -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,