From 727bb845922ef87bddda934e96decf76f66a24bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 2 Sep 2021 18:58:34 +0200 Subject: [PATCH] stmgr: drop MethdosMap --- chain/consensus/filcns/compute_state.go | 5 ----- chain/stmgr/utils.go | 2 -- cli/chain.go | 4 ++-- cli/multisig.go | 9 ++++----- cli/services.go | 4 ++-- cli/state.go | 4 ++-- cmd/lotus-shed/msg.go | 4 ++-- cmd/lotus-wallet/interactive.go | 6 +++--- cmd/tvx/extract_many.go | 5 ++--- lotuspond/front/src/chain/methodgen.go | 5 +++-- 10 files changed, 20 insertions(+), 28 deletions(-) diff --git a/chain/consensus/filcns/compute_state.go b/chain/consensus/filcns/compute_state.go index 7e2007c69f5..e0557b79734 100644 --- a/chain/consensus/filcns/compute_state.go +++ b/chain/consensus/filcns/compute_state.go @@ -32,11 +32,6 @@ import ( "github.com/filecoin-project/lotus/metrics" ) -func init() { - // todo this is a hack, should fix the cli deps, and drop the map in stmgr - stmgr.MethodsMap = NewActorRegistry().Methods -} - func NewActorRegistry() *vm.ActorRegistry { inv := vm.NewActorRegistry() diff --git a/chain/stmgr/utils.go b/chain/stmgr/utils.go index ad03106022c..42ef56e0493 100644 --- a/chain/stmgr/utils.go +++ b/chain/stmgr/utils.go @@ -22,8 +22,6 @@ import ( "github.com/filecoin-project/lotus/node/modules/dtypes" ) -var MethodsMap map[cid.Cid]map[abi.MethodNum]vm.MethodMeta - func GetReturnType(ctx context.Context, sm *StateManager, to address.Address, method abi.MethodNum, ts *types.TipSet) (cbg.CBORUnmarshaler, error) { act, err := sm.LoadActor(ctx, to, ts) if err != nil { diff --git a/cli/chain.go b/cli/chain.go index 875dcb21aaa..0cbdaa0f703 100644 --- a/cli/chain.go +++ b/cli/chain.go @@ -35,7 +35,7 @@ import ( "github.com/filecoin-project/lotus/api/v0api" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors" - "github.com/filecoin-project/lotus/chain/stmgr" + "github.com/filecoin-project/lotus/chain/consensus/filcns" types "github.com/filecoin-project/lotus/chain/types" ) @@ -476,7 +476,7 @@ var ChainInspectUsage = &cli.Command{ return err } - mm := stmgr.MethodsMap[code][m.Message.Method] + mm := filcns.NewActorRegistry().Methods[code][m.Message.Method] // TODO: use remote map byMethod[mm.Name] += m.Message.GasLimit byMethodC[mm.Name]++ diff --git a/cli/multisig.go b/cli/multisig.go index c51677d85ca..7b93e55f911 100644 --- a/cli/multisig.go +++ b/cli/multisig.go @@ -10,10 +10,6 @@ import ( "strconv" "text/tabwriter" - "github.com/filecoin-project/lotus/chain/actors/builtin" - - "github.com/filecoin-project/lotus/chain/actors" - "github.com/filecoin-project/lotus/chain/stmgr" cbg "github.com/whyrusleeping/cbor-gen" "github.com/filecoin-project/go-state-types/big" @@ -31,8 +27,11 @@ import ( "github.com/filecoin-project/lotus/blockstore" "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/multisig" + "github.com/filecoin-project/lotus/chain/consensus/filcns" "github.com/filecoin-project/lotus/chain/types" ) @@ -325,7 +324,7 @@ var msigInspectCmd = &cli.Command{ fmt.Fprintf(w, "%d\t%s\t%d\t%s\t%s\t%s(%d)\t%s\n", txid, "pending", len(tx.Approved), target, types.FIL(tx.Value), "new account, unknown method", tx.Method, paramStr) } } else { - method := stmgr.MethodsMap[targAct.Code][tx.Method] + method := filcns.NewActorRegistry().Methods[targAct.Code][tx.Method] // TODO: use remote map if decParams && tx.Method != 0 { ptyp := reflect.New(method.Params.Elem()).Interface().(cbg.CBORUnmarshaler) diff --git a/cli/services.go b/cli/services.go index 0923680aa08..8d131dfb1f7 100644 --- a/cli/services.go +++ b/cli/services.go @@ -12,7 +12,7 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/chain/stmgr" + "github.com/filecoin-project/lotus/chain/consensus/filcns" types "github.com/filecoin-project/lotus/chain/types" cid "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -86,7 +86,7 @@ func (s *ServicesImpl) DecodeTypedParamsFromJSON(ctx context.Context, to address return nil, err } - methodMeta, found := stmgr.MethodsMap[act.Code][method] + methodMeta, found := filcns.NewActorRegistry().Methods[act.Code][method] // TODO: use remote map if !found { return nil, fmt.Errorf("method %d not found on actor %s", method, act.Code) } diff --git a/cli/state.go b/cli/state.go index 375630c9ff1..bac7efae8eb 100644 --- a/cli/state.go +++ b/cli/state.go @@ -1367,7 +1367,7 @@ func codeStr(c cid.Cid) string { } func getMethod(code cid.Cid, method abi.MethodNum) string { - return stmgr.MethodsMap[code][method].Name + return filcns.NewActorRegistry().Methods[code][method].Name // todo: use remote } func toFil(f types.BigInt) types.FIL { @@ -1412,7 +1412,7 @@ func JsonParams(code cid.Cid, method abi.MethodNum, params []byte) (string, erro } func jsonReturn(code cid.Cid, method abi.MethodNum, ret []byte) (string, error) { - methodMeta, found := stmgr.MethodsMap[code][method] + methodMeta, found := filcns.NewActorRegistry().Methods[code][method] // TODO: use remote if !found { return "", fmt.Errorf("method %d not found on actor %s", method, code) } diff --git a/cmd/lotus-shed/msg.go b/cmd/lotus-shed/msg.go index c966b2e97ab..b640fb9c9cb 100644 --- a/cmd/lotus-shed/msg.go +++ b/cmd/lotus-shed/msg.go @@ -15,7 +15,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/big" - "github.com/filecoin-project/lotus/chain/stmgr" + "github.com/filecoin-project/lotus/chain/consensus/filcns" "github.com/filecoin-project/lotus/chain/types" lcli "github.com/filecoin-project/lotus/cli" "github.com/filecoin-project/specs-actors/v2/actors/builtin/multisig" @@ -140,7 +140,7 @@ func printMessage(cctx *cli.Context, msg *types.Message) error { return nil } - fmt.Println("Method:", stmgr.MethodsMap[toact.Code][msg.Method].Name) + fmt.Println("Method:", filcns.NewActorRegistry().Methods[toact.Code][msg.Method].Name) // todo use remote p, err := lcli.JsonParams(toact.Code, msg.Method, msg.Params) if err != nil { return err diff --git a/cmd/lotus-wallet/interactive.go b/cmd/lotus-wallet/interactive.go index e1ad2cbb292..40c3f892231 100644 --- a/cmd/lotus-wallet/interactive.go +++ b/cmd/lotus-wallet/interactive.go @@ -23,7 +23,7 @@ import ( "github.com/filecoin-project/lotus/api/v0api" "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/actors/builtin/multisig" - "github.com/filecoin-project/lotus/chain/stmgr" + "github.com/filecoin-project/lotus/chain/consensus/filcns" "github.com/filecoin-project/lotus/chain/types" lcli "github.com/filecoin-project/lotus/cli" ) @@ -103,7 +103,7 @@ func (c *InteractiveWallet) WalletSign(ctx context.Context, k address.Address, m return xerrors.Errorf("looking up dest actor: %w", err) } - fmt.Println("Method:", stmgr.MethodsMap[toact.Code][cmsg.Method].Name) + fmt.Println("Method:", filcns.NewActorRegistry().Methods[toact.Code][cmsg.Method].Name) p, err := lcli.JsonParams(toact.Code, cmsg.Method, cmsg.Params) if err != nil { return err @@ -125,7 +125,7 @@ func (c *InteractiveWallet) WalletSign(ctx context.Context, k address.Address, m return xerrors.Errorf("looking up msig dest actor: %w", err) } - fmt.Println("\tMultiSig Proposal Method:", stmgr.MethodsMap[toact.Code][mp.Method].Name) + fmt.Println("\tMultiSig Proposal Method:", filcns.NewActorRegistry().Methods[toact.Code][mp.Method].Name) // todo use remote p, err := lcli.JsonParams(toact.Code, mp.Method, mp.Params) if err != nil { return err diff --git a/cmd/tvx/extract_many.go b/cmd/tvx/extract_many.go index 081678a1726..ae196542e87 100644 --- a/cmd/tvx/extract_many.go +++ b/cmd/tvx/extract_many.go @@ -13,12 +13,11 @@ import ( "github.com/fatih/color" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/exitcode" + "github.com/filecoin-project/lotus/chain/consensus/filcns" "github.com/hashicorp/go-multierror" "github.com/ipfs/go-cid" "github.com/multiformats/go-multihash" "github.com/urfave/cli/v2" - - "github.com/filecoin-project/lotus/chain/stmgr" ) var extractManyFlags struct { @@ -158,7 +157,7 @@ func runExtractMany(c *cli.Context) error { } // Lookup the method in actor method table. - if m, ok := stmgr.MethodsMap[codeCid]; !ok { + if m, ok := filcns.NewActorRegistry().Methods[codeCid]; !ok { return fmt.Errorf("unrecognized actor: %s", actorcode) } else if methodnum >= len(m) { return fmt.Errorf("unrecognized method number for actor %s: %d", actorcode, methodnum) diff --git a/lotuspond/front/src/chain/methodgen.go b/lotuspond/front/src/chain/methodgen.go index 5a00d5e6e38..057ec7d0112 100644 --- a/lotuspond/front/src/chain/methodgen.go +++ b/lotuspond/front/src/chain/methodgen.go @@ -8,7 +8,8 @@ import ( "github.com/multiformats/go-multihash" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/lotus/chain/stmgr" + + "github.com/filecoin-project/lotus/chain/consensus/filcns" ) func main() { @@ -44,7 +45,7 @@ func main() { out := map[string][]string{} - for c, methods := range stmgr.MethodsMap { + for c, methods := range filcns.NewActorRegistry().Methods { cmh, err := multihash.Decode(c.Hash()) if err != nil { panic(err)