Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: shed: print out actor code CIDs in manifest cid checker #8911

Merged
merged 1 commit into from
Jun 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions cmd/lotus-shed/cid.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import (
"encoding/hex"
"fmt"
"os"
"text/tabwriter"

"github.com/ipfs/go-cid"
cbor "github.com/ipfs/go-ipld-cbor"
"github.com/ipld/go-car"
mh "github.com/multiformats/go-multihash"
"github.com/urfave/cli/v2"
Expand All @@ -15,14 +17,16 @@ import (
"github.com/filecoin-project/go-state-types/abi"

"github.com/filecoin-project/lotus/blockstore"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
)

var cidCmd = &cli.Command{
Name: "cid",
Usage: "Cid command",
Subcommands: cli.Commands{
cidIdCmd,
cidFromCarCmd,
inspectBundleCmd,
},
}

Expand Down Expand Up @@ -90,9 +94,9 @@ var cidIdCmd = &cli.Command{
},
}

var cidFromCarCmd = &cli.Command{
Name: "manifest-cid-from-car",
Usage: "Get the manifest CID from a car file",
var inspectBundleCmd = &cli.Command{
Name: "inspect-bundle",
Usage: "Get the manifest CID from a car file, as well as the actor code CIDs",
ArgsUsage: "[path]",
Action: func(cctx *cli.Context) error {
ctx := cctx.Context
Expand All @@ -104,6 +108,7 @@ var cidFromCarCmd = &cli.Command{
}

bs := blockstore.NewMemory()
wrapBs := adt.WrapStore(ctx, cbor.NewCborStore(bs))

hdr, err := car.LoadCar(ctx, bs, f)
if err != nil {
Expand All @@ -114,6 +119,19 @@ var cidFromCarCmd = &cli.Command{

fmt.Printf("Manifest CID: %s\n", manifestCid.String())

return nil
entries, err := actors.ReadManifest(ctx, wrapBs, manifestCid)
if err != nil {
return xerrors.Errorf("error loading manifest: %w", err)
}

tw := tabwriter.NewWriter(os.Stdout, 2, 4, 2, ' ', 0)
_, _ = fmt.Fprintln(tw, "\nActor\tCID\t")

for name, cid := range entries {
_, _ = fmt.Fprintf(tw, "%v\t%v\n", name, cid)

}

return tw.Flush()
},
}