Skip to content

Commit

Permalink
Merge pull request #6099 from filecoin-project/feat/pick-10965-from-l…
Browse files Browse the repository at this point in the history
…otus

feat: set tipset to the given epoch by default
  • Loading branch information
simlecode authored Aug 15, 2023
2 parents e757b70 + 626bdee commit ba8f91b
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions cmd/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,13 +733,24 @@ var StateComputeStateCmd = &cmds.Command{
Run: func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) error {
ctx := req.Context

ts, err := LoadTipSet(ctx, req, getEnv(env).ChainAPI)
h, _ := req.Options["vm-height"].(uint64)
height := abi.ChainEpoch(h)
var ts *types.TipSet
var err error
chainAPI := getEnv(env).ChainAPI
if tss := req.Options["tipset"].(string); tss != "" {
ts, err = ParseTipSetRef(ctx, chainAPI, tss)
} else if height > 0 {
ts, err = chainAPI.ChainGetTipSetByHeight(ctx, height, types.EmptyTSK)
} else {
ts, err = chainAPI.ChainHead(ctx)
}
if err != nil {
return err
}
h, _ := req.Options["vm-height"].(uint64)
if h == 0 {
h = uint64(ts.Height())

if height == 0 {
height = ts.Height()
}

var msgs []*types.Message
Expand Down Expand Up @@ -768,7 +779,7 @@ var StateComputeStateCmd = &cmds.Command{

stout = &o
} else {
o, err := getEnv(env).ChainAPI.StateCompute(ctx, abi.ChainEpoch(h), msgs, ts.Key())
o, err := getEnv(env).ChainAPI.StateCompute(ctx, height, msgs, ts.Key())
if err != nil {
return err
}
Expand Down

0 comments on commit ba8f91b

Please sign in to comment.