Skip to content

Commit

Permalink
stmgr: drop MethdosMap
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Sep 2, 2021
1 parent 30fccaa commit 727bb84
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 28 deletions.
5 changes: 0 additions & 5 deletions chain/consensus/filcns/compute_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 0 additions & 2 deletions chain/stmgr/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions cli/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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]++
Expand Down
9 changes: 4 additions & 5 deletions cli/multisig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
)

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions cli/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions cli/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/lotus-shed/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions cmd/lotus-wallet/interactive.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 2 additions & 3 deletions cmd/tvx/extract_many.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions lotuspond/front/src/chain/methodgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 727bb84

Please sign in to comment.