Merge pull request #8670 from filecoin-project/jen/actorcid

chore: state: add cli to get the manifest & actor cid for network v16 & up
This commit is contained in:
Jiaying Wang 2022-05-30 15:31:22 -04:00 committed by GitHub
commit 5b3a6e89ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 108 additions and 14 deletions

View File

@ -20,7 +20,7 @@ const GenesisFile = ""
var NetworkBundle = "devnet"
const GenesisNetworkVersion = network.Version15
const GenesisNetworkVersion = network.Version16
var UpgradeBreezeHeight = abi.ChainEpoch(-1)

View File

@ -32,6 +32,22 @@ const (
VerifregKey = "verifiedregistry"
)
func GetBuiltinActorsKeys() []string {
return []string{
AccountKey,
CronKey,
InitKey,
MarketKey,
MinerKey,
MultisigKey,
PaychKey,
PowerKey,
RewardKey,
SystemKey,
VerifregKey,
}
}
var (
manifestMx sync.RWMutex
)
@ -85,19 +101,8 @@ func loadManifests(ctx context.Context, store cbor.IpldStore) error {
manifests[av] = mf
for _, name := range []string{
AccountKey,
CronKey,
InitKey,
MarketKey,
MinerKey,
MultisigKey,
PaychKey,
PowerKey,
RewardKey,
SystemKey,
VerifregKey,
} {
var actorKeys = GetBuiltinActorsKeys()
for _, name := range actorKeys {
c, ok := mf.Get(name)
if ok {
actorMeta[c] = actorEntry{name: name, version: av}

View File

@ -15,8 +15,13 @@ import (
"sort"
"strconv"
"strings"
"text/tabwriter"
"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/lotus/chain/consensus/filcns"
@ -79,6 +84,7 @@ var StateCmd = &cli.Command{
StateExecTraceCmd,
StateNtwkVersionCmd,
StateMinerProvingDeadlineCmd,
StateSysActorCIDsCmd,
},
}
@ -1872,3 +1878,71 @@ var StateNtwkVersionCmd = &cli.Command{
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")
var actorKeys = actors.GetBuiltinActorsKeys()
for _, name := range actorKeys {
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()
},
}

View File

@ -1749,6 +1749,7 @@ COMMANDS:
exec-trace Get the execution trace of a given message
network-version Returns the network version
miner-proving-deadline Retrieve information about a given miner's proving deadline
actor-cids Returns the built-in actor bundle manifest ID & system actor cids
help, h Shows a list of commands or help for one command
OPTIONS:
@ -2094,6 +2095,20 @@ OPTIONS:
```
### lotus state actor-cids
```
NAME:
lotus state actor-cids - Returns the built-in actor bundle manifest ID & system actor cids
USAGE:
lotus state actor-cids [command options] [arguments...]
OPTIONS:
--network-version value specify network version (default: 16)
--help, -h show help (default: false)
```
## lotus chain
```
NAME: