Merge branch 'master' into refactor/lib/blockstore
This commit is contained in:
+1
-1
@@ -46,7 +46,7 @@ func BackupCmd(repoFlag string, rt repo.RepoType, getApi BackupApiFn) *cli.Comma
|
||||
}
|
||||
defer lr.Close() // nolint:errcheck
|
||||
|
||||
mds, err := lr.Datastore("/metadata")
|
||||
mds, err := lr.Datastore(context.TODO(), "/metadata")
|
||||
if err != nil {
|
||||
return xerrors.Errorf("getting metadata datastore: %w", err)
|
||||
}
|
||||
|
||||
+1
-1
@@ -324,6 +324,6 @@ var Commands = []*cli.Command{
|
||||
}
|
||||
|
||||
func WithCategory(cat string, cmd *cli.Command) *cli.Command {
|
||||
cmd.Category = cat
|
||||
cmd.Category = strings.ToUpper(cat)
|
||||
return cmd
|
||||
}
|
||||
|
||||
+21
-13
@@ -20,10 +20,14 @@ import (
|
||||
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/store"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var disputeLog = logging.Logger("disputer")
|
||||
|
||||
const Confidence = 10
|
||||
|
||||
type minerDeadline struct {
|
||||
@@ -165,13 +169,13 @@ var disputerStartCmd = &cli.Command{
|
||||
startEpoch = abi.ChainEpoch(cctx.Uint64("height"))
|
||||
}
|
||||
|
||||
fmt.Println("checking sync status")
|
||||
disputeLog.Info("checking sync status")
|
||||
|
||||
if err := SyncWait(ctx, api, false); err != nil {
|
||||
return xerrors.Errorf("sync wait: %w", err)
|
||||
}
|
||||
|
||||
fmt.Println("setting up window post disputer")
|
||||
disputeLog.Info("setting up window post disputer")
|
||||
|
||||
// subscribe to head changes and validate the current value
|
||||
|
||||
@@ -220,10 +224,10 @@ var disputerStartCmd = &cli.Command{
|
||||
statusCheckTicker := time.NewTicker(time.Hour)
|
||||
defer statusCheckTicker.Stop()
|
||||
|
||||
fmt.Println("starting up window post disputer")
|
||||
disputeLog.Info("starting up window post disputer")
|
||||
|
||||
applyTsk := func(tsk types.TipSetKey) error {
|
||||
log.Infof("last checked height: %d", lastEpoch)
|
||||
disputeLog.Infow("last checked epoch", "epoch", lastEpoch)
|
||||
dls, ok := deadlineMap[lastEpoch]
|
||||
delete(deadlineMap, lastEpoch)
|
||||
if !ok || startEpoch >= lastEpoch {
|
||||
@@ -261,12 +265,12 @@ var disputerStartCmd = &cli.Command{
|
||||
|
||||
// TODO: Parallelizeable / can be integrated into the previous deadline-iterating for loop
|
||||
for _, dpmsg := range dpmsgs {
|
||||
log.Infof("disputing a PoSt from miner %s", dpmsg.To)
|
||||
disputeLog.Infow("disputing a PoSt", "miner", dpmsg.To)
|
||||
m, err := api.MpoolPushMessage(ctx, dpmsg, mss)
|
||||
if err != nil {
|
||||
log.Infof("failed to dispute post message: %s", err.Error())
|
||||
disputeLog.Errorw("failed to dispute post message", "err", err.Error(), "miner", dpmsg.To)
|
||||
} else {
|
||||
log.Infof("disputed a PoSt in message: %s", m.Cid())
|
||||
disputeLog.Infof("submited dispute", "mcid", m.Cid(), "miner", dpmsg.To)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,7 +300,7 @@ var disputerStartCmd = &cli.Command{
|
||||
}
|
||||
}
|
||||
case <-statusCheckTicker.C:
|
||||
log.Infof("Running status check: ")
|
||||
disputeLog.Infof("running status check")
|
||||
|
||||
minerList, err = api.StateListMiners(ctx, types.EmptyTSK)
|
||||
if err != nil {
|
||||
@@ -321,14 +325,14 @@ var disputerStartCmd = &cli.Command{
|
||||
// if an epoch got "skipped" from the deadlineMap somehow, just fry it now instead of letting it sit around forever
|
||||
_, ok := deadlineMap[lastStatusCheckEpoch]
|
||||
if ok {
|
||||
log.Infof("epoch %d was skipped during execution, deleting it from deadlineMap")
|
||||
disputeLog.Infow("epoch skipped during execution, deleting it from deadlineMap", "epoch", lastStatusCheckEpoch)
|
||||
delete(deadlineMap, lastStatusCheckEpoch)
|
||||
}
|
||||
}
|
||||
|
||||
log.Infof("Status check complete")
|
||||
log.Infof("status check complete")
|
||||
case <-ctx.Done():
|
||||
return xerrors.Errorf("context cancelled")
|
||||
return ctx.Err()
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -336,10 +340,14 @@ var disputerStartCmd = &cli.Command{
|
||||
|
||||
for {
|
||||
err := disputeLoop()
|
||||
if err != nil {
|
||||
fmt.Println("disputer shutting down: ", err)
|
||||
if err == context.Canceled {
|
||||
disputeLog.Info("disputer shutting down")
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
disputeLog.Errorw("disputer shutting down", "err", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
+1
-1
@@ -93,7 +93,7 @@ var logSetLevel = &cli.Command{
|
||||
|
||||
for _, system := range systems {
|
||||
if err := api.LogSetLevel(ctx, system, cctx.Args().First()); err != nil {
|
||||
return xerrors.Errorf("setting log level on %s: %w", system, err)
|
||||
return xerrors.Errorf("setting log level on %s: %v", system, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+74
-50
@@ -935,6 +935,10 @@ var stateComputeStateCmd = &cli.Command{
|
||||
Name: "compute-state-output",
|
||||
Usage: "a json file containing pre-existing compute-state output, to generate html reports without rerunning state changes",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "no-timing",
|
||||
Usage: "don't show timing information in html traces",
|
||||
},
|
||||
},
|
||||
Action: func(cctx *cli.Context) error {
|
||||
api, closer, err := GetFullNodeAPI(cctx)
|
||||
@@ -1026,7 +1030,9 @@ var stateComputeStateCmd = &cli.Command{
|
||||
return c.Code, nil
|
||||
}
|
||||
|
||||
return ComputeStateHTMLTempl(os.Stdout, ts, stout, getCode)
|
||||
_, _ = fmt.Fprintln(os.Stderr, "computed state cid: ", stout.Root)
|
||||
|
||||
return ComputeStateHTMLTempl(os.Stdout, ts, stout, !cctx.Bool("no-timing"), getCode)
|
||||
}
|
||||
|
||||
fmt.Println("computed state cid: ", stout.Root)
|
||||
@@ -1147,8 +1153,11 @@ var compStateMsg = `
|
||||
{{if gt (len .Msg.Params) 0}}
|
||||
<div><pre class="params">{{JsonParams ($code) (.Msg.Method) (.Msg.Params) | html}}</pre></div>
|
||||
{{end}}
|
||||
<div><span class="slow-{{IsSlow .Duration}}-{{IsVerySlow .Duration}}">Took {{.Duration}}</span>, <span class="exit{{IntExit .MsgRct.ExitCode}}">Exit: <b>{{.MsgRct.ExitCode}}</b></span>{{if gt (len .MsgRct.Return) 0}}, Return{{end}}</div>
|
||||
|
||||
{{if PrintTiming}}
|
||||
<div><span class="slow-{{IsSlow .Duration}}-{{IsVerySlow .Duration}}">Took {{.Duration}}</span>, <span class="exit{{IntExit .MsgRct.ExitCode}}">Exit: <b>{{.MsgRct.ExitCode}}</b></span>{{if gt (len .MsgRct.Return) 0}}, Return{{end}}</div>
|
||||
{{else}}
|
||||
<div><span class="exit{{IntExit .MsgRct.ExitCode}}">Exit: <b>{{.MsgRct.ExitCode}}</b></span>{{if gt (len .MsgRct.Return) 0}}, Return{{end}}</div>
|
||||
{{end}}
|
||||
{{if gt (len .MsgRct.Return) 0}}
|
||||
<div><pre class="ret">{{JsonReturn ($code) (.Msg.Method) (.MsgRct.Return) | html}}</pre></div>
|
||||
{{end}}
|
||||
@@ -1174,7 +1183,7 @@ var compStateMsg = `
|
||||
{{range .GasCharges}}
|
||||
<tr><td>{{.Name}}{{if .Extra}}:{{.Extra}}{{end}}</td>
|
||||
{{template "gasC" .}}
|
||||
<td>{{.TimeTaken}}</td>
|
||||
<td>{{if PrintTiming}}{{.TimeTaken}}{{end}}</td>
|
||||
<td>
|
||||
{{ $fImp := FirstImportant .Location }}
|
||||
{{ if $fImp }}
|
||||
@@ -1213,7 +1222,7 @@ var compStateMsg = `
|
||||
{{with SumGas .GasCharges}}
|
||||
<tr class="sum"><td><b>Sum</b></td>
|
||||
{{template "gasC" .}}
|
||||
<td>{{.TimeTaken}}</td>
|
||||
<td>{{if PrintTiming}}{{.TimeTaken}}{{end}}</td>
|
||||
<td></td></tr>
|
||||
{{end}}
|
||||
</table>
|
||||
@@ -1234,19 +1243,20 @@ type compStateHTMLIn struct {
|
||||
Comp *api.ComputeStateOutput
|
||||
}
|
||||
|
||||
func ComputeStateHTMLTempl(w io.Writer, ts *types.TipSet, o *api.ComputeStateOutput, getCode func(addr address.Address) (cid.Cid, error)) error {
|
||||
func ComputeStateHTMLTempl(w io.Writer, ts *types.TipSet, o *api.ComputeStateOutput, printTiming bool, getCode func(addr address.Address) (cid.Cid, error)) error {
|
||||
t, err := template.New("compute_state").Funcs(map[string]interface{}{
|
||||
"GetCode": getCode,
|
||||
"GetMethod": getMethod,
|
||||
"ToFil": toFil,
|
||||
"JsonParams": JsonParams,
|
||||
"JsonReturn": jsonReturn,
|
||||
"IsSlow": isSlow,
|
||||
"IsVerySlow": isVerySlow,
|
||||
"IntExit": func(i exitcode.ExitCode) int64 { return int64(i) },
|
||||
"SumGas": sumGas,
|
||||
"CodeStr": codeStr,
|
||||
"Call": call,
|
||||
"GetCode": getCode,
|
||||
"GetMethod": getMethod,
|
||||
"ToFil": toFil,
|
||||
"JsonParams": JsonParams,
|
||||
"JsonReturn": jsonReturn,
|
||||
"IsSlow": isSlow,
|
||||
"IsVerySlow": isVerySlow,
|
||||
"IntExit": func(i exitcode.ExitCode) int64 { return int64(i) },
|
||||
"SumGas": sumGas,
|
||||
"CodeStr": codeStr,
|
||||
"Call": call,
|
||||
"PrintTiming": func() bool { return printTiming },
|
||||
"FirstImportant": func(locs []types.Loc) *types.Loc {
|
||||
if len(locs) != 0 {
|
||||
for _, l := range locs {
|
||||
@@ -1393,34 +1403,10 @@ var stateWaitMsgCmd = &cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("message was executed in tipset: %s\n", mw.TipSet.Cids())
|
||||
fmt.Printf("Exit Code: %d\n", mw.Receipt.ExitCode)
|
||||
fmt.Printf("Gas Used: %d\n", mw.Receipt.GasUsed)
|
||||
fmt.Printf("Return: %x\n", mw.Receipt.Return)
|
||||
if err := printReceiptReturn(ctx, api, m, mw.Receipt); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return printMsg(ctx, api, msg, mw, m)
|
||||
},
|
||||
}
|
||||
|
||||
func printReceiptReturn(ctx context.Context, api api.FullNode, m *types.Message, r types.MessageReceipt) error {
|
||||
act, err := api.StateGetActor(ctx, m.To, types.EmptyTSK)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
jret, err := jsonReturn(act.Code, m.Method, r.Return)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println(jret)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var stateSearchMsgCmd = &cli.Command{
|
||||
Name: "search-msg",
|
||||
Usage: "Search to see whether a message has appeared on chain",
|
||||
@@ -1448,18 +1434,56 @@ var stateSearchMsgCmd = &cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
if mw != nil {
|
||||
fmt.Printf("message was executed in tipset: %s", mw.TipSet.Cids())
|
||||
fmt.Printf("\nExit Code: %d", mw.Receipt.ExitCode)
|
||||
fmt.Printf("\nGas Used: %d", mw.Receipt.GasUsed)
|
||||
fmt.Printf("\nReturn: %x", mw.Receipt.Return)
|
||||
} else {
|
||||
fmt.Print("message was not found on chain")
|
||||
m, err := api.ChainGetMessage(ctx, msg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
return printMsg(ctx, api, msg, mw, m)
|
||||
},
|
||||
}
|
||||
|
||||
func printReceiptReturn(ctx context.Context, api api.FullNode, m *types.Message, r types.MessageReceipt) error {
|
||||
if len(r.Return) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
act, err := api.StateGetActor(ctx, m.To, types.EmptyTSK)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
jret, err := jsonReturn(act.Code, m.Method, r.Return)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("Decoded return value: ", jret)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func printMsg(ctx context.Context, api api.FullNode, msg cid.Cid, mw *lapi.MsgLookup, m *types.Message) error {
|
||||
if mw != nil {
|
||||
if mw.Message != msg {
|
||||
fmt.Printf("Message was replaced: %s\n", mw.Message)
|
||||
}
|
||||
|
||||
fmt.Printf("Executed in tipset: %s\n", mw.TipSet.Cids())
|
||||
fmt.Printf("Exit Code: %d\n", mw.Receipt.ExitCode)
|
||||
fmt.Printf("Gas Used: %d\n", mw.Receipt.GasUsed)
|
||||
fmt.Printf("Return: %x\n", mw.Receipt.Return)
|
||||
} else {
|
||||
fmt.Println("message was not found on chain")
|
||||
}
|
||||
|
||||
if err := printReceiptReturn(ctx, api, m, mw.Receipt); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var stateCallCmd = &cli.Command{
|
||||
Name: "call",
|
||||
Usage: "Invoke a method on an actor locally",
|
||||
|
||||
Reference in New Issue
Block a user