feat: shed tool to report on any consensus mismatches in history
This commit is contained in:
parent
727a71186b
commit
0d8a3cbaf8
@ -86,6 +86,7 @@ func main() {
|
||||
replayOfflineCmd,
|
||||
msgindexCmd,
|
||||
FevmAnalyticsCmd,
|
||||
mismatchesCmd,
|
||||
}
|
||||
|
||||
app := &cli.App{
|
||||
|
53
cmd/lotus-shed/mismatches.go
Normal file
53
cmd/lotus-shed/mismatches.go
Normal file
@ -0,0 +1,53 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
lcli "github.com/filecoin-project/lotus/cli"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var mismatchesCmd = &cli.Command{
|
||||
Name: "mismatches",
|
||||
Description: "Walk up the chain, recomputing state, and reporting any mismatches",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
srv, err := lcli.GetFullNodeServices(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer srv.Close() //nolint:errcheck
|
||||
|
||||
api := srv.FullNodeAPI()
|
||||
ctx := lcli.ReqContext(cctx)
|
||||
|
||||
checkTs, err := api.ChainHead(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for checkTs.Height() != 0 {
|
||||
if checkTs.Height()%10000 == 0 {
|
||||
fmt.Println("Reached height ", checkTs.Height())
|
||||
}
|
||||
|
||||
execTsk := checkTs.Parents()
|
||||
execTs, err := api.ChainGetTipSet(ctx, execTsk)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
st, err := api.StateCompute(ctx, execTs.Height(), nil, execTsk)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if st.Root != checkTs.ParentState() {
|
||||
fmt.Println("consensus mismatch found at height ", execTs.Height())
|
||||
}
|
||||
|
||||
checkTs = execTs
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
Loading…
Reference in New Issue
Block a user