From 0d8a3cbaf848d15169f25bff0920d3c804b1b186 Mon Sep 17 00:00:00 2001 From: Aayush Date: Wed, 26 Apr 2023 10:07:52 -0400 Subject: [PATCH 1/2] feat: shed tool to report on any consensus mismatches in history --- cmd/lotus-shed/main.go | 1 + cmd/lotus-shed/mismatches.go | 53 ++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 cmd/lotus-shed/mismatches.go diff --git a/cmd/lotus-shed/main.go b/cmd/lotus-shed/main.go index 1f4d953f99..9cb1cd32cc 100644 --- a/cmd/lotus-shed/main.go +++ b/cmd/lotus-shed/main.go @@ -86,6 +86,7 @@ func main() { replayOfflineCmd, msgindexCmd, FevmAnalyticsCmd, + mismatchesCmd, } app := &cli.App{ diff --git a/cmd/lotus-shed/mismatches.go b/cmd/lotus-shed/mismatches.go new file mode 100644 index 0000000000..8dd1be3523 --- /dev/null +++ b/cmd/lotus-shed/mismatches.go @@ -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 + }, +} From b4c2c249db5022789405a0de4eb9dc72a0521a30 Mon Sep 17 00:00:00 2001 From: Aayush Date: Fri, 28 Apr 2023 13:48:05 -0400 Subject: [PATCH 2/2] chore: deps: update to FVM 3.3.1 --- cmd/lotus-shed/mismatches.go | 3 ++- extern/filecoin-ffi | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/lotus-shed/mismatches.go b/cmd/lotus-shed/mismatches.go index 8dd1be3523..223158e0fe 100644 --- a/cmd/lotus-shed/mismatches.go +++ b/cmd/lotus-shed/mismatches.go @@ -3,8 +3,9 @@ package main import ( "fmt" - lcli "github.com/filecoin-project/lotus/cli" "github.com/urfave/cli/v2" + + lcli "github.com/filecoin-project/lotus/cli" ) var mismatchesCmd = &cli.Command{ diff --git a/extern/filecoin-ffi b/extern/filecoin-ffi index 86698251ab..de34caff94 160000 --- a/extern/filecoin-ffi +++ b/extern/filecoin-ffi @@ -1 +1 @@ -Subproject commit 86698251ab87eec6944320a01998623155c01276 +Subproject commit de34caff946d598edb299566d951b44b9b7f7dd4