stmgr: drop MethdosMap

This commit is contained in:
Łukasz Magiera 2021-09-02 18:58:34 +02:00
parent 30fccaa0bd
commit 727bb84592
10 changed files with 20 additions and 28 deletions

View File

@ -32,11 +32,6 @@ import (
"github.com/filecoin-project/lotus/metrics" "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 { func NewActorRegistry() *vm.ActorRegistry {
inv := vm.NewActorRegistry() inv := vm.NewActorRegistry()

View File

@ -22,8 +22,6 @@ import (
"github.com/filecoin-project/lotus/node/modules/dtypes" "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) { 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) act, err := sm.LoadActor(ctx, to, ts)
if err != nil { if err != nil {

View File

@ -35,7 +35,7 @@ import (
"github.com/filecoin-project/lotus/api/v0api" "github.com/filecoin-project/lotus/api/v0api"
"github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors" "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" types "github.com/filecoin-project/lotus/chain/types"
) )
@ -476,7 +476,7 @@ var ChainInspectUsage = &cli.Command{
return err 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 byMethod[mm.Name] += m.Message.GasLimit
byMethodC[mm.Name]++ byMethodC[mm.Name]++

View File

@ -10,10 +10,6 @@ import (
"strconv" "strconv"
"text/tabwriter" "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" cbg "github.com/whyrusleeping/cbor-gen"
"github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/big"
@ -31,8 +27,11 @@ import (
"github.com/filecoin-project/lotus/blockstore" "github.com/filecoin-project/lotus/blockstore"
"github.com/filecoin-project/lotus/build" "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/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors/builtin/multisig" "github.com/filecoin-project/lotus/chain/actors/builtin/multisig"
"github.com/filecoin-project/lotus/chain/consensus/filcns"
"github.com/filecoin-project/lotus/chain/types" "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) 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 { } 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 { if decParams && tx.Method != 0 {
ptyp := reflect.New(method.Params.Elem()).Interface().(cbg.CBORUnmarshaler) ptyp := reflect.New(method.Params.Elem()).Interface().(cbg.CBORUnmarshaler)

View File

@ -12,7 +12,7 @@ import (
"github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/lotus/api" "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" types "github.com/filecoin-project/lotus/chain/types"
cid "github.com/ipfs/go-cid" cid "github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen" cbg "github.com/whyrusleeping/cbor-gen"
@ -86,7 +86,7 @@ func (s *ServicesImpl) DecodeTypedParamsFromJSON(ctx context.Context, to address
return nil, err return nil, err
} }
methodMeta, found := stmgr.MethodsMap[act.Code][method] methodMeta, found := filcns.NewActorRegistry().Methods[act.Code][method] // TODO: use remote map
if !found { if !found {
return nil, fmt.Errorf("method %d not found on actor %s", method, act.Code) return nil, fmt.Errorf("method %d not found on actor %s", method, act.Code)
} }

View File

@ -1367,7 +1367,7 @@ func codeStr(c cid.Cid) string {
} }
func getMethod(code cid.Cid, method abi.MethodNum) 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 { 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) { 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 { if !found {
return "", fmt.Errorf("method %d not found on actor %s", method, code) return "", fmt.Errorf("method %d not found on actor %s", method, code)
} }

View File

@ -15,7 +15,7 @@ import (
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/big" "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" "github.com/filecoin-project/lotus/chain/types"
lcli "github.com/filecoin-project/lotus/cli" lcli "github.com/filecoin-project/lotus/cli"
"github.com/filecoin-project/specs-actors/v2/actors/builtin/multisig" "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 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) p, err := lcli.JsonParams(toact.Code, msg.Method, msg.Params)
if err != nil { if err != nil {
return err return err

View File

@ -23,7 +23,7 @@ import (
"github.com/filecoin-project/lotus/api/v0api" "github.com/filecoin-project/lotus/api/v0api"
"github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors/builtin/multisig" "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" "github.com/filecoin-project/lotus/chain/types"
lcli "github.com/filecoin-project/lotus/cli" 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) 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) p, err := lcli.JsonParams(toact.Code, cmsg.Method, cmsg.Params)
if err != nil { if err != nil {
return err 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) 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) p, err := lcli.JsonParams(toact.Code, mp.Method, mp.Params)
if err != nil { if err != nil {
return err return err

View File

@ -13,12 +13,11 @@ import (
"github.com/fatih/color" "github.com/fatih/color"
"github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/exitcode" "github.com/filecoin-project/go-state-types/exitcode"
"github.com/filecoin-project/lotus/chain/consensus/filcns"
"github.com/hashicorp/go-multierror" "github.com/hashicorp/go-multierror"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
"github.com/multiformats/go-multihash" "github.com/multiformats/go-multihash"
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
"github.com/filecoin-project/lotus/chain/stmgr"
) )
var extractManyFlags struct { var extractManyFlags struct {
@ -158,7 +157,7 @@ func runExtractMany(c *cli.Context) error {
} }
// Lookup the method in actor method table. // 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) return fmt.Errorf("unrecognized actor: %s", actorcode)
} else if methodnum >= len(m) { } else if methodnum >= len(m) {
return fmt.Errorf("unrecognized method number for actor %s: %d", actorcode, methodnum) return fmt.Errorf("unrecognized method number for actor %s: %d", actorcode, methodnum)

View File

@ -8,7 +8,8 @@ import (
"github.com/multiformats/go-multihash" "github.com/multiformats/go-multihash"
"github.com/filecoin-project/go-state-types/abi" "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() { func main() {
@ -44,7 +45,7 @@ func main() {
out := map[string][]string{} out := map[string][]string{}
for c, methods := range stmgr.MethodsMap { for c, methods := range filcns.NewActorRegistry().Methods {
cmh, err := multihash.Decode(c.Hash()) cmh, err := multihash.Decode(c.Hash())
if err != nil { if err != nil {
panic(err) panic(err)