Merge pull request #10965 from filecoin-project/steb/use-ts-from-height

feat: cli(compute-state) default to the tipset at the given epoch
This commit is contained in:
Łukasz Magiera 2023-06-09 09:19:50 -05:00 committed by GitHub
commit 28951e5919
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1065,12 +1065,19 @@ var StateComputeStateCmd = &cli.Command{
ctx := ReqContext(cctx)
ts, err := LoadTipSet(ctx, cctx, api)
h := abi.ChainEpoch(cctx.Uint64("vm-height"))
var ts *types.TipSet
if tss := cctx.String("tipset"); tss != "" {
ts, err = ParseTipSetRef(ctx, api, tss)
} else if h > 0 {
ts, err = api.ChainGetTipSetByHeight(ctx, h, types.EmptyTSK)
} else {
ts, err = api.ChainHead(ctx)
}
if err != nil {
return err
}
h := abi.ChainEpoch(cctx.Uint64("vm-height"))
if h == 0 {
h = ts.Height()
}