add cli to get the actor cid forthe current network version
This commit is contained in:
parent
2a5e36c542
commit
2c1cf42aa0
@ -20,7 +20,7 @@ const GenesisFile = ""
|
|||||||
|
|
||||||
var NetworkBundle = "devnet"
|
var NetworkBundle = "devnet"
|
||||||
|
|
||||||
const GenesisNetworkVersion = network.Version15
|
const GenesisNetworkVersion = network.Version16
|
||||||
|
|
||||||
var UpgradeBreezeHeight = abi.ChainEpoch(-1)
|
var UpgradeBreezeHeight = abi.ChainEpoch(-1)
|
||||||
|
|
||||||
|
85
cli/state.go
85
cli/state.go
@ -15,8 +15,13 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"text/tabwriter"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-state-types/network"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-state-types/big"
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
"github.com/filecoin-project/lotus/chain/consensus/filcns"
|
"github.com/filecoin-project/lotus/chain/consensus/filcns"
|
||||||
|
|
||||||
@ -79,6 +84,7 @@ var StateCmd = &cli.Command{
|
|||||||
StateExecTraceCmd,
|
StateExecTraceCmd,
|
||||||
StateNtwkVersionCmd,
|
StateNtwkVersionCmd,
|
||||||
StateMinerProvingDeadlineCmd,
|
StateMinerProvingDeadlineCmd,
|
||||||
|
StateSysActorCIDsCmd,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1872,3 +1878,82 @@ var StateNtwkVersionCmd = &cli.Command{
|
|||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var StateSysActorCIDsCmd = &cli.Command{
|
||||||
|
Name: "actor-cids",
|
||||||
|
Usage: "Returns the built-in actor bundle manifest ID & system actor cids",
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
&cli.UintFlag{
|
||||||
|
Name: "network-version",
|
||||||
|
Usage: "specify network version",
|
||||||
|
Value: uint(build.NewestNetworkVersion),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Action: func(cctx *cli.Context) error {
|
||||||
|
if cctx.Args().Present() {
|
||||||
|
return ShowHelp(cctx, fmt.Errorf("doesn't expect any arguments"))
|
||||||
|
}
|
||||||
|
|
||||||
|
api, closer, err := GetFullNodeAPI(cctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer closer()
|
||||||
|
|
||||||
|
ctx := ReqContext(cctx)
|
||||||
|
|
||||||
|
ts, err := LoadTipSet(ctx, cctx, api)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
nv, err := api.StateNetworkVersion(ctx, ts.Key())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if cctx.IsSet("network-version") {
|
||||||
|
nv = network.Version(cctx.Uint64("network-version"))
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("Network Version: %d\n", nv)
|
||||||
|
|
||||||
|
actorVersion, err := actors.VersionForNetwork(nv)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
fmt.Printf("Actor Version: %d\n", actorVersion)
|
||||||
|
|
||||||
|
manifestCid, ok := actors.GetManifest(actorVersion)
|
||||||
|
if !ok {
|
||||||
|
return xerrors.Errorf("cannot get manifest CID")
|
||||||
|
}
|
||||||
|
fmt.Printf("Manifest CID: %v\n", manifestCid)
|
||||||
|
|
||||||
|
tw := tabwriter.NewWriter(os.Stdout, 2, 4, 2, ' ', 0)
|
||||||
|
_, _ = fmt.Fprintln(tw, "\nActor\tCID\t")
|
||||||
|
|
||||||
|
for _, name := range []string{
|
||||||
|
actors.AccountKey,
|
||||||
|
actors.CronKey,
|
||||||
|
actors.InitKey,
|
||||||
|
actors.MarketKey,
|
||||||
|
actors.MinerKey,
|
||||||
|
actors.MultisigKey,
|
||||||
|
actors.PaychKey,
|
||||||
|
actors.PowerKey,
|
||||||
|
actors.RewardKey,
|
||||||
|
actors.SystemKey,
|
||||||
|
actors.VerifregKey,
|
||||||
|
} {
|
||||||
|
sysActorCID, ok := actors.GetActorCodeID(actorVersion, name)
|
||||||
|
if !ok {
|
||||||
|
return xerrors.Errorf("error getting actor %v code id for actor version %d", name,
|
||||||
|
actorVersion)
|
||||||
|
}
|
||||||
|
_, _ = fmt.Fprintf(tw, "%v\t%v\n", name, sysActorCID)
|
||||||
|
|
||||||
|
}
|
||||||
|
return tw.Flush()
|
||||||
|
},
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user