Skip to content

Commit

Permalink
Remove old functions for getting actors cids
Browse files Browse the repository at this point in the history
  • Loading branch information
geoff-vball committed Jun 29, 2022
1 parent 8637964 commit 378d204
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 593 deletions.
364 changes: 0 additions & 364 deletions chain/actors/builtin/builtin.go

Large diffs are not rendered by default.

188 changes: 0 additions & 188 deletions chain/actors/builtin/builtin.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions chain/actors/builtin/multisig/message.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -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}}


Expand Down Expand Up @@ -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")
}

Expand Down
5 changes: 2 additions & 3 deletions chain/actors/builtin/multisig/message8.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
}

Expand Down
8 changes: 3 additions & 5 deletions chain/gen/genesis/f00_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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{
Expand Down
8 changes: 4 additions & 4 deletions chain/gen/genesis/f02_reward.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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{
Expand Down
8 changes: 4 additions & 4 deletions chain/gen/genesis/f03_cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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{
Expand Down
8 changes: 4 additions & 4 deletions chain/gen/genesis/f04_power.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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{
Expand Down
8 changes: 4 additions & 4 deletions chain/gen/genesis/f05_market.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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{
Expand Down
8 changes: 4 additions & 4 deletions chain/gen/genesis/f06_vreg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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{
Expand Down
Loading

0 comments on commit 378d204

Please sign in to comment.