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:
commit
5b3a6e89ff
@ -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)
|
||||||
|
|
||||||
|
@ -32,6 +32,22 @@ const (
|
|||||||
VerifregKey = "verifiedregistry"
|
VerifregKey = "verifiedregistry"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func GetBuiltinActorsKeys() []string {
|
||||||
|
return []string{
|
||||||
|
AccountKey,
|
||||||
|
CronKey,
|
||||||
|
InitKey,
|
||||||
|
MarketKey,
|
||||||
|
MinerKey,
|
||||||
|
MultisigKey,
|
||||||
|
PaychKey,
|
||||||
|
PowerKey,
|
||||||
|
RewardKey,
|
||||||
|
SystemKey,
|
||||||
|
VerifregKey,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
manifestMx sync.RWMutex
|
manifestMx sync.RWMutex
|
||||||
)
|
)
|
||||||
@ -85,19 +101,8 @@ func loadManifests(ctx context.Context, store cbor.IpldStore) error {
|
|||||||
|
|
||||||
manifests[av] = mf
|
manifests[av] = mf
|
||||||
|
|
||||||
for _, name := range []string{
|
var actorKeys = GetBuiltinActorsKeys()
|
||||||
AccountKey,
|
for _, name := range actorKeys {
|
||||||
CronKey,
|
|
||||||
InitKey,
|
|
||||||
MarketKey,
|
|
||||||
MinerKey,
|
|
||||||
MultisigKey,
|
|
||||||
PaychKey,
|
|
||||||
PowerKey,
|
|
||||||
RewardKey,
|
|
||||||
SystemKey,
|
|
||||||
VerifregKey,
|
|
||||||
} {
|
|
||||||
c, ok := mf.Get(name)
|
c, ok := mf.Get(name)
|
||||||
if ok {
|
if ok {
|
||||||
actorMeta[c] = actorEntry{name: name, version: av}
|
actorMeta[c] = actorEntry{name: name, version: av}
|
||||||
|
74
cli/state.go
74
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,71 @@ 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")
|
||||||
|
|
||||||
|
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()
|
||||||
|
},
|
||||||
|
}
|
||||||
|
@ -1749,6 +1749,7 @@ COMMANDS:
|
|||||||
exec-trace Get the execution trace of a given message
|
exec-trace Get the execution trace of a given message
|
||||||
network-version Returns the network version
|
network-version Returns the network version
|
||||||
miner-proving-deadline Retrieve information about a given miner's proving deadline
|
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
|
help, h Shows a list of commands or help for one command
|
||||||
|
|
||||||
OPTIONS:
|
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
|
## lotus chain
|
||||||
```
|
```
|
||||||
NAME:
|
NAME:
|
||||||
|
Loading…
Reference in New Issue
Block a user