Merge pull request #6142 from filecoin-project/fix/tipset-cli

fix: use a consistent tipset in commands
This commit is contained in:
Łukasz Magiera 2021-04-29 18:35:17 +02:00 committed by GitHub
commit 002eb4e812
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 4 additions and 55 deletions

View File

@ -723,12 +723,6 @@ var ChainGetCmd = &cli.Command{
return err
}
if ts == nil {
ts, err = api.ChainHead(ctx)
if err != nil {
return err
}
}
p = "/ipfs/" + ts.ParentState().String() + p
if cctx.Bool("verbose") {
fmt.Println(p)

View File

@ -180,10 +180,13 @@ func ParseTipSetString(ts string) ([]cid.Cid, error) {
return cids, nil
}
// LoadTipSet gets the tipset from the context, or the head from the API.
//
// It always gets the head from the API so commands use a consistent tipset even if time pases.
func LoadTipSet(ctx context.Context, cctx *cli.Context, api v0api.FullNode) (*types.TipSet, error) {
tss := cctx.String("tipset")
if tss == "" {
return nil, nil
return api.ChainHead(ctx)
}
return ParseTipSetRef(ctx, api, tss)
@ -850,14 +853,6 @@ var StateListMessagesCmd = &cli.Command{
return err
}
if ts == nil {
head, err := api.ChainHead(ctx)
if err != nil {
return err
}
ts = head
}
windowSize := abi.ChainEpoch(100)
cur := ts
@ -957,13 +952,6 @@ var StateComputeStateCmd = &cli.Command{
}
h := abi.ChainEpoch(cctx.Uint64("vm-height"))
if ts == nil {
head, err := api.ChainHead(ctx)
if err != nil {
return err
}
ts = head
}
if h == 0 {
h = ts.Height()
}
@ -1765,13 +1753,6 @@ var StateSectorCmd = &cli.Command{
return err
}
if ts == nil {
ts, err = api.ChainHead(ctx)
if err != nil {
return err
}
}
maddr, err := address.NewFromString(cctx.Args().Get(0))
if err != nil {
return err

View File

@ -35,12 +35,6 @@ var frozenMinersCmd = &cli.Command{
if err != nil {
return err
}
if ts == nil {
ts, err = api.ChainHead(ctx)
if err != nil {
return err
}
}
queryEpoch := ts.Height()

View File

@ -49,12 +49,6 @@ var postFindCmd = &cli.Command{
if err != nil {
return err
}
if startTs == nil {
startTs, err = api.ChainHead(ctx)
if err != nil {
return err
}
}
stopEpoch := startTs.Height() - abi.ChainEpoch(c.Int("lookback"))
if verbose {
fmt.Printf("Collecting messages between %d and %d\n", startTs.Height(), stopEpoch)

View File

@ -56,13 +56,6 @@ var staterootDiffsCmd = &cli.Command{
return err
}
if ts == nil {
ts, err = api.ChainHead(ctx)
if err != nil {
return err
}
}
fn := func(ts *types.TipSet) (cid.Cid, []cid.Cid) {
blk := ts.Blocks()[0]
strt := blk.ParentStateRoot
@ -134,13 +127,6 @@ var staterootStatCmd = &cli.Command{
return err
}
if ts == nil {
ts, err = api.ChainHead(ctx)
if err != nil {
return err
}
}
var addrs []address.Address
for _, inp := range cctx.Args().Slice() {