From 425661772d59f2ba5a1f7548598e42d64b644d84 Mon Sep 17 00:00:00 2001 From: mx Date: Tue, 30 May 2023 14:33:35 +0800 Subject: [PATCH 1/8] style:Refactoring slashfilter --- chain/gen/slashfilter/slashfilter.go | 45 +++++----- cmd/lotus/daemon.go | 128 ++++++++++++++++++++++++++- 2 files changed, 151 insertions(+), 22 deletions(-) diff --git a/chain/gen/slashfilter/slashfilter.go b/chain/gen/slashfilter/slashfilter.go index 986586267..f5f5ec502 100644 --- a/chain/gen/slashfilter/slashfilter.go +++ b/chain/gen/slashfilter/slashfilter.go @@ -27,24 +27,24 @@ func New(dstore ds.Batching) *SlashFilter { } } -func (f *SlashFilter) MinedBlock(ctx context.Context, bh *types.BlockHeader, parentEpoch abi.ChainEpoch) error { +func (f *SlashFilter) CheckBlock(ctx context.Context, bh *types.BlockHeader, parentEpoch abi.ChainEpoch) (cid.Cid, error) { if build.IsNearUpgrade(bh.Height, build.UpgradeOrangeHeight) { - return nil + return cid.Undef, nil } epochKey := ds.NewKey(fmt.Sprintf("/%s/%d", bh.Miner, bh.Height)) { // double-fork mining (2 blocks at one epoch) - if err := checkFault(ctx, f.byEpoch, epochKey, bh, "double-fork mining faults"); err != nil { - return err + if witness, err := checkFault(ctx, f.byEpoch, epochKey, bh, "double-fork mining faults"); err != nil { + return witness, err } } parentsKey := ds.NewKey(fmt.Sprintf("/%s/%x", bh.Miner, types.NewTipSetKey(bh.Parents...).Bytes())) { // time-offset mining faults (2 blocks with the same parents) - if err := checkFault(ctx, f.byParents, parentsKey, bh, "time-offset mining faults"); err != nil { - return err + if witness, err := checkFault(ctx, f.byParents, parentsKey, bh, "time-offset mining faults"); err != nil { + return witness, err } } @@ -55,19 +55,19 @@ func (f *SlashFilter) MinedBlock(ctx context.Context, bh *types.BlockHeader, par parentEpochKey := ds.NewKey(fmt.Sprintf("/%s/%d", bh.Miner, parentEpoch)) have, err := f.byEpoch.Has(ctx, parentEpochKey) if err != nil { - return err + return cid.Undef, err } if have { // If we had, make sure it's in our parent tipset cidb, err := f.byEpoch.Get(ctx, parentEpochKey) if err != nil { - return xerrors.Errorf("getting other block cid: %w", err) + return cid.Undef, xerrors.Errorf("getting other block cid: %w", err) } _, parent, err := cid.CidFromBytes(cidb) if err != nil { - return err + return cid.Undef, err } var found bool @@ -78,45 +78,50 @@ func (f *SlashFilter) MinedBlock(ctx context.Context, bh *types.BlockHeader, par } if !found { - return xerrors.Errorf("produced block would trigger 'parent-grinding fault' consensus fault; miner: %s; bh: %s, expected parent: %s", bh.Miner, bh.Cid(), parent) + return cid.Undef, xerrors.Errorf("produced block would trigger 'parent-grinding fault' consensus fault; miner: %s; bh: %s, expected parent: %s", bh.Miner, bh.Cid(), parent) } } } if err := f.byParents.Put(ctx, parentsKey, bh.Cid().Bytes()); err != nil { - return xerrors.Errorf("putting byEpoch entry: %w", err) + return cid.Undef, xerrors.Errorf("putting byEpoch entry: %w", err) } if err := f.byEpoch.Put(ctx, epochKey, bh.Cid().Bytes()); err != nil { - return xerrors.Errorf("putting byEpoch entry: %w", err) + return cid.Undef, xerrors.Errorf("putting byEpoch entry: %w", err) } - return nil + return cid.Undef, nil } -func checkFault(ctx context.Context, t ds.Datastore, key ds.Key, bh *types.BlockHeader, faultType string) error { +func (f *SlashFilter) MinedBlock(ctx context.Context, bh *types.BlockHeader, parentEpoch abi.ChainEpoch) error { + _, err := f.CheckBlock(ctx, bh, parentEpoch) + return err +} + +func checkFault(ctx context.Context, t ds.Datastore, key ds.Key, bh *types.BlockHeader, faultType string) (cid.Cid, error) { fault, err := t.Has(ctx, key) if err != nil { - return err + return cid.Undef, err } if fault { cidb, err := t.Get(ctx, key) if err != nil { - return xerrors.Errorf("getting other block cid: %w", err) + return cid.Undef, xerrors.Errorf("getting other block cid: %w", err) } _, other, err := cid.CidFromBytes(cidb) if err != nil { - return err + return cid.Undef, err } if other == bh.Cid() { - return nil + return cid.Undef, nil } - return xerrors.Errorf("produced block would trigger '%s' consensus fault; miner: %s; bh: %s, other: %s", faultType, bh.Miner, bh.Cid(), other) + return other, xerrors.Errorf("produced block would trigger '%s' consensus fault; miner: %s; bh: %s, other: %s", faultType, bh.Miner, bh.Cid(), other) } - return nil + return cid.Undef, nil } diff --git a/cmd/lotus/daemon.go b/cmd/lotus/daemon.go index fbb9dfd9a..7af8e79a0 100644 --- a/cmd/lotus/daemon.go +++ b/cmd/lotus/daemon.go @@ -9,6 +9,15 @@ import ( "encoding/hex" "encoding/json" "fmt" + "github.com/filecoin-project/go-address" + cborutil "github.com/filecoin-project/go-cbor-util" + "github.com/filecoin-project/go-state-types/builtin" + "github.com/filecoin-project/lotus/chain/actors" + "github.com/filecoin-project/lotus/chain/gen/slashfilter" + "github.com/filecoin-project/specs-actors/actors/builtin/miner" + "github.com/ipfs/go-cid" + levelds "github.com/ipfs/go-ds-leveldb" + ldbopts "github.com/syndtr/goleveldb/leveldb/opt" "io" "os" "path" @@ -29,7 +38,6 @@ import ( "github.com/filecoin-project/go-jsonrpc" "github.com/filecoin-project/go-paramfetch" - lapi "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/consensus" @@ -160,6 +168,19 @@ var DaemonCmd = &cli.Command{ Name: "restore-config", Usage: "config file to use when restoring from backup", }, + &cli.BoolFlag{ + Name: "slash-consensus", + Usage: "Report consensus fault", + Value: false, + }, + &cli.StringFlag{ + Name: "slasher-sender", + Usage: "optionally specify the account to report consensus from", + }, + &cli.StringFlag{ + Name: "slashdb-dir", + Value: "slash watch db dir path", + }, }, Action: func(cctx *cli.Context) error { isLite := cctx.Bool("lite") @@ -380,7 +401,14 @@ var DaemonCmd = &cli.Command{ if err != nil { return fmt.Errorf("failed to start json-rpc endpoint: %s", err) } - + if cctx.IsSet("slash-consensus") && cctx.IsSet("slashdb-dir") { + go func() { + err := slashConsensus(api, cctx.String("slashdb-dir"), cctx.String("slasher-sender")) + if err != nil { + panic("slashConsensus error") + } + }() + } // Monitor for shutdown. finishCh := node.MonitorShutdown(shutdownChan, node.ShutdownHandler{Component: "rpc server", StopFunc: rpcStopper}, @@ -574,3 +602,99 @@ func ImportChain(ctx context.Context, r repo.Repo, fname string, snapshot bool) return nil } + +func slashConsensus(a lapi.FullNode, p string, from string) error { + ctx := context.Background() + var fromAddr address.Address + + ds, err := levelds.NewDatastore(p, &levelds.Options{ + Compression: ldbopts.NoCompression, + NoSync: false, + Strict: ldbopts.StrictAll, + ReadOnly: false, + }) + if err != nil { + return xerrors.Errorf("open leveldb: %w", err) + } + sf := slashfilter.New(ds) + if from == "" { + defaddr, err := a.WalletDefaultAddress(ctx) + if err != nil { + return err + } + fromAddr = defaddr + } else { + addr, err := address.NewFromString(from) + if err != nil { + return err + } + + fromAddr = addr + } + + blocks, err := a.SyncIncomingBlocks(ctx) + if err != nil { + return xerrors.Errorf("sync incoming blocks failed: %w", err) + } + for block := range blocks { + log.Infof("deal with block: %d, %v, %s", block.Height, block.Miner, block.Cid()) + if otherBlock, err := slashFilterMinedBlock(ctx, sf, a, block); err != nil { + if otherBlock == nil { + continue + } + log.Errorf(" SLASH FILTER ERROR: %s", err) + bh1, err := cborutil.Dump(otherBlock) + if err != nil { + log.Errorf("could not dump otherblock:%s, err:%s", otherBlock.Cid(), err) + continue + } + + bh2, err := cborutil.Dump(block) + if err != nil { + log.Errorf("could not dump block:%s, err:%s", block.Cid(), err) + continue + } + + params := miner.ReportConsensusFaultParams{ + BlockHeader1: bh1, + BlockHeader2: bh2, + } + + enc, err := actors.SerializeParams(¶ms) + if err != nil { + log.Errorf("could not serialize declare faults parameters: %s", err) + continue + } + message, err := a.MpoolPushMessage(ctx, &types.Message{ + To: block.Miner, + From: fromAddr, + Value: types.NewInt(0), + Method: builtin.MethodsMiner.ReportConsensusFault, + Params: enc, + }, nil) + if err != nil { + log.Errorf("ReportConsensusFault to messagepool error:%s", err) + continue + } + log.Infof("ReportConsensusFault message CID:%s", message.Cid()) + + } + } + return err +} + +func slashFilterMinedBlock(ctx context.Context, sf *slashfilter.SlashFilter, a lapi.FullNode, bh *types.BlockHeader) (*types.BlockHeader, error) { + parent, err := a.ChainGetBlock(ctx, bh.Parents[0]) + if err != nil { + return nil, xerrors.Errorf("chain get block error:%s", err) + } + otherCid, err := sf.CheckBlock(ctx, bh, parent.Height) + if err != nil { + return nil, xerrors.Errorf("slash filter check block error:%s", err) + } + if otherCid != cid.Undef { + otherHeader, err := a.ChainGetBlock(ctx, otherCid) + return otherHeader, xerrors.Errorf("chain get other block error:%s", err) + } + return nil, nil +} From d365f7b0a132f428f2365e0b2dec7d764c9c806b Mon Sep 17 00:00:00 2001 From: "huangxinheng@storswift.com" Date: Tue, 30 May 2023 07:01:24 +0000 Subject: [PATCH 2/8] fix: docs gen --- cmd/lotus/daemon.go | 19 ++++++++++--------- documentation/en/cli-lotus.md | 3 +++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/cmd/lotus/daemon.go b/cmd/lotus/daemon.go index 7af8e79a0..1a81d780c 100644 --- a/cmd/lotus/daemon.go +++ b/cmd/lotus/daemon.go @@ -9,15 +9,6 @@ import ( "encoding/hex" "encoding/json" "fmt" - "github.com/filecoin-project/go-address" - cborutil "github.com/filecoin-project/go-cbor-util" - "github.com/filecoin-project/go-state-types/builtin" - "github.com/filecoin-project/lotus/chain/actors" - "github.com/filecoin-project/lotus/chain/gen/slashfilter" - "github.com/filecoin-project/specs-actors/actors/builtin/miner" - "github.com/ipfs/go-cid" - levelds "github.com/ipfs/go-ds-leveldb" - ldbopts "github.com/syndtr/goleveldb/leveldb/opt" "io" "os" "path" @@ -25,9 +16,12 @@ import ( "strings" "github.com/DataDog/zstd" + "github.com/ipfs/go-cid" + levelds "github.com/ipfs/go-ds-leveldb" metricsprom "github.com/ipfs/go-metrics-prometheus" "github.com/mitchellh/go-homedir" "github.com/multiformats/go-multiaddr" + ldbopts "github.com/syndtr/goleveldb/leveldb/opt" "github.com/urfave/cli/v2" "go.opencensus.io/plugin/runmetrics" "go.opencensus.io/stats" @@ -36,12 +30,19 @@ import ( "golang.org/x/xerrors" "gopkg.in/cheggaaa/pb.v1" + "github.com/filecoin-project/go-address" + cborutil "github.com/filecoin-project/go-cbor-util" "github.com/filecoin-project/go-jsonrpc" "github.com/filecoin-project/go-paramfetch" + "github.com/filecoin-project/go-state-types/builtin" + "github.com/filecoin-project/specs-actors/actors/builtin/miner" + lapi "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/consensus" "github.com/filecoin-project/lotus/chain/consensus/filcns" + "github.com/filecoin-project/lotus/chain/gen/slashfilter" "github.com/filecoin-project/lotus/chain/index" "github.com/filecoin-project/lotus/chain/stmgr" "github.com/filecoin-project/lotus/chain/store" diff --git a/documentation/en/cli-lotus.md b/documentation/en/cli-lotus.md index 9fe755cde..7ece0b58e 100644 --- a/documentation/en/cli-lotus.md +++ b/documentation/en/cli-lotus.md @@ -75,6 +75,9 @@ OPTIONS: --api-max-req-size value maximum API request size accepted by the JSON RPC server (default: 0) --restore value restore from backup file --restore-config value config file to use when restoring from backup + --slash-consensus Report consensus fault (default: false) + --slasher-sender value optionally specify the account to report consensus from + --slashdb-dir value (default: "slash watch db dir path") --help, -h show help (default: false) ``` From 42aa8451f8ee27cea310b04991a689f76287c6d4 Mon Sep 17 00:00:00 2001 From: swift-mx Date: Tue, 30 May 2023 23:54:07 +0800 Subject: [PATCH 3/8] fix: error log Co-authored-by: Aayush Rajasekaran --- cmd/lotus/daemon.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/lotus/daemon.go b/cmd/lotus/daemon.go index 1a81d780c..e86bc1e31 100644 --- a/cmd/lotus/daemon.go +++ b/cmd/lotus/daemon.go @@ -674,7 +674,7 @@ func slashConsensus(a lapi.FullNode, p string, from string) error { Params: enc, }, nil) if err != nil { - log.Errorf("ReportConsensusFault to messagepool error:%s", err) + log.Errorf("ReportConsensusFault to messagepool error:%w", err) continue } log.Infof("ReportConsensusFault message CID:%s", message.Cid()) From 196cd0b73903a3fcc571a8d4a5812f93eff11a80 Mon Sep 17 00:00:00 2001 From: swift-mx Date: Wed, 31 May 2023 00:06:50 +0800 Subject: [PATCH 4/8] fix: add more log for error --- chain/gen/slashfilter/slashfilter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chain/gen/slashfilter/slashfilter.go b/chain/gen/slashfilter/slashfilter.go index f5f5ec502..e23c601df 100644 --- a/chain/gen/slashfilter/slashfilter.go +++ b/chain/gen/slashfilter/slashfilter.go @@ -102,7 +102,7 @@ func (f *SlashFilter) MinedBlock(ctx context.Context, bh *types.BlockHeader, par func checkFault(ctx context.Context, t ds.Datastore, key ds.Key, bh *types.BlockHeader, faultType string) (cid.Cid, error) { fault, err := t.Has(ctx, key) if err != nil { - return cid.Undef, err + return cid.Undef, xerrors.Errorf("failed to read from datastore: %w", err) } if fault { From 16b9787db9713af8db0d8761b310a43c2077b96a Mon Sep 17 00:00:00 2001 From: mx Date: Thu, 8 Jun 2023 18:49:39 +0800 Subject: [PATCH 5/8] fix: handle the parent-grinding mining fault --- cmd/lotus/daemon.go | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/cmd/lotus/daemon.go b/cmd/lotus/daemon.go index e86bc1e31..11f3aca72 100644 --- a/cmd/lotus/daemon.go +++ b/cmd/lotus/daemon.go @@ -684,12 +684,12 @@ func slashConsensus(a lapi.FullNode, p string, from string) error { return err } -func slashFilterMinedBlock(ctx context.Context, sf *slashfilter.SlashFilter, a lapi.FullNode, bh *types.BlockHeader) (*types.BlockHeader, error) { - parent, err := a.ChainGetBlock(ctx, bh.Parents[0]) +func slashFilterMinedBlock(ctx context.Context, sf *slashfilter.SlashFilter, a lapi.FullNode, blockB *types.BlockHeader) (*types.BlockHeader, error) { + blockC, err := a.ChainGetBlock(ctx, blockB.Parents[0]) if err != nil { return nil, xerrors.Errorf("chain get block error:%s", err) } - otherCid, err := sf.CheckBlock(ctx, bh, parent.Height) + otherCid, err := sf.CheckBlock(ctx, blockB, blockC.Height) if err != nil { return nil, xerrors.Errorf("slash filter check block error:%s", err) } @@ -697,5 +697,20 @@ func slashFilterMinedBlock(ctx context.Context, sf *slashfilter.SlashFilter, a l otherHeader, err := a.ChainGetBlock(ctx, otherCid) return otherHeader, xerrors.Errorf("chain get other block error:%s", err) } + blockA, err := a.ChainGetBlock(ctx, otherCid) + + // (c) parent-grinding fault + // Here extra is the "witness", a third block that shows the connection between A and B as + // A's sibling and B's parent. + // Specifically, since A is of lower height, it must be that B was mined omitting A from its tipset + // + // B + // | + // [A, C] + if types.CidArrsEqual(blockA.Parents, blockC.Parents) && blockA.Height == blockC.Height && + types.CidArrsContains(blockB.Parents, blockC.Cid()) && !types.CidArrsContains(blockB.Parents, blockA.Cid()) { + return blockC, xerrors.Errorf("chain get other block error:%s", err) + } + return nil, nil } From 2fca475dd44ca6f018165c777558d54d936c32ad Mon Sep 17 00:00:00 2001 From: mx Date: Fri, 9 Jun 2023 10:15:14 +0800 Subject: [PATCH 6/8] fix: supply extra params for ReportConsensusFaultParams --- chain/gen/slashfilter/slashfilter.go | 9 ++------- cmd/lotus/daemon.go | 24 ++++++++++++++++-------- miner/miner.go | 2 +- node/impl/full/sync.go | 2 +- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/chain/gen/slashfilter/slashfilter.go b/chain/gen/slashfilter/slashfilter.go index 89ddd90b1..0d78be49e 100644 --- a/chain/gen/slashfilter/slashfilter.go +++ b/chain/gen/slashfilter/slashfilter.go @@ -26,7 +26,7 @@ func New(dstore ds.Batching) *SlashFilter { } } -func (f *SlashFilter) CheckBlock(ctx context.Context, bh *types.BlockHeader, parentEpoch abi.ChainEpoch) (cid.Cid, error) { +func (f *SlashFilter) MinedBlock(ctx context.Context, bh *types.BlockHeader, parentEpoch abi.ChainEpoch) (cid.Cid, error) { epochKey := ds.NewKey(fmt.Sprintf("/%s/%d", bh.Miner, bh.Height)) { // double-fork mining (2 blocks at one epoch) @@ -73,7 +73,7 @@ func (f *SlashFilter) CheckBlock(ctx context.Context, bh *types.BlockHeader, par } if !found { - return cid.Undef, xerrors.Errorf("produced block would trigger 'parent-grinding fault' consensus fault; miner: %s; bh: %s, expected parent: %s", bh.Miner, bh.Cid(), parent) + return parent, xerrors.Errorf("produced block would trigger 'parent-grinding fault' consensus fault; miner: %s; bh: %s, expected parent: %s", bh.Miner, bh.Cid(), parent) } } } @@ -89,11 +89,6 @@ func (f *SlashFilter) CheckBlock(ctx context.Context, bh *types.BlockHeader, par return cid.Undef, nil } -func (f *SlashFilter) MinedBlock(ctx context.Context, bh *types.BlockHeader, parentEpoch abi.ChainEpoch) error { - _, err := f.CheckBlock(ctx, bh, parentEpoch) - return err -} - func checkFault(ctx context.Context, t ds.Datastore, key ds.Key, bh *types.BlockHeader, faultType string) (cid.Cid, error) { fault, err := t.Has(ctx, key) if err != nil { diff --git a/cmd/lotus/daemon.go b/cmd/lotus/daemon.go index 11f3aca72..106446c0a 100644 --- a/cmd/lotus/daemon.go +++ b/cmd/lotus/daemon.go @@ -639,7 +639,7 @@ func slashConsensus(a lapi.FullNode, p string, from string) error { } for block := range blocks { log.Infof("deal with block: %d, %v, %s", block.Height, block.Miner, block.Cid()) - if otherBlock, err := slashFilterMinedBlock(ctx, sf, a, block); err != nil { + if otherBlock, extraBlock, err := slashFilterMinedBlock(ctx, sf, a, block); err != nil { if otherBlock == nil { continue } @@ -660,6 +660,14 @@ func slashConsensus(a lapi.FullNode, p string, from string) error { BlockHeader1: bh1, BlockHeader2: bh2, } + if extraBlock != nil { + be, err := cborutil.Dump(extraBlock) + if err != nil { + log.Errorf("could not dump block:%s, err:%s", block.Cid(), err) + continue + } + params.BlockHeaderExtra = be + } enc, err := actors.SerializeParams(¶ms) if err != nil { @@ -684,18 +692,18 @@ func slashConsensus(a lapi.FullNode, p string, from string) error { return err } -func slashFilterMinedBlock(ctx context.Context, sf *slashfilter.SlashFilter, a lapi.FullNode, blockB *types.BlockHeader) (*types.BlockHeader, error) { +func slashFilterMinedBlock(ctx context.Context, sf *slashfilter.SlashFilter, a lapi.FullNode, blockB *types.BlockHeader) (*types.BlockHeader, *types.BlockHeader, error) { blockC, err := a.ChainGetBlock(ctx, blockB.Parents[0]) if err != nil { - return nil, xerrors.Errorf("chain get block error:%s", err) + return nil, nil, xerrors.Errorf("chain get block error:%s", err) } - otherCid, err := sf.CheckBlock(ctx, blockB, blockC.Height) + otherCid, err := sf.MinedBlock(ctx, blockB, blockC.Height) if err != nil { - return nil, xerrors.Errorf("slash filter check block error:%s", err) + return nil, nil, xerrors.Errorf("slash filter check block error:%s", err) } if otherCid != cid.Undef { otherHeader, err := a.ChainGetBlock(ctx, otherCid) - return otherHeader, xerrors.Errorf("chain get other block error:%s", err) + return otherHeader, nil, xerrors.Errorf("chain get other block error:%s", err) } blockA, err := a.ChainGetBlock(ctx, otherCid) @@ -709,8 +717,8 @@ func slashFilterMinedBlock(ctx context.Context, sf *slashfilter.SlashFilter, a l // [A, C] if types.CidArrsEqual(blockA.Parents, blockC.Parents) && blockA.Height == blockC.Height && types.CidArrsContains(blockB.Parents, blockC.Cid()) && !types.CidArrsContains(blockB.Parents, blockA.Cid()) { - return blockC, xerrors.Errorf("chain get other block error:%s", err) + return blockA, blockC, xerrors.Errorf("chain get other block error:%s", err) } - return nil, nil + return nil, nil, nil } diff --git a/miner/miner.go b/miner/miner.go index 0d3e12de8..e1737009b 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -324,7 +324,7 @@ minerLoop: "block-time", btime, "time", build.Clock.Now(), "difference", build.Clock.Since(btime)) } - if err := m.sf.MinedBlock(ctx, b.Header, base.TipSet.Height()+base.NullRounds); err != nil { + if _, err = m.sf.MinedBlock(ctx, b.Header, base.TipSet.Height()+base.NullRounds); err != nil { log.Errorf(" SLASH FILTER ERROR: %s", err) if os.Getenv("LOTUS_MINER_NO_SLASHFILTER") != "_yes_i_know_i_can_and_probably_will_lose_all_my_fil_and_power_" { continue diff --git a/node/impl/full/sync.go b/node/impl/full/sync.go index fda55def1..9be43338e 100644 --- a/node/impl/full/sync.go +++ b/node/impl/full/sync.go @@ -58,7 +58,7 @@ func (a *SyncAPI) SyncSubmitBlock(ctx context.Context, blk *types.BlockMsg) erro } if a.SlashFilter != nil && os.Getenv("LOTUS_NO_SLASHFILTER") != "_yes_i_know_i_can_and_probably_will_lose_all_my_fil_and_power_" { - if err := a.SlashFilter.MinedBlock(ctx, blk.Header, parent.Height); err != nil { + if _, err = a.SlashFilter.MinedBlock(ctx, blk.Header, parent.Height); err != nil { log.Errorf(" SLASH FILTER ERROR: %s", err) return xerrors.Errorf(" SLASH FILTER ERROR: %w", err) } From 173dad45edf75c71ea8799743fbe566ae45839f7 Mon Sep 17 00:00:00 2001 From: "huangxinheng@storswift.com" Date: Fri, 9 Jun 2023 02:34:10 +0000 Subject: [PATCH 7/8] fix: docs gen --- documentation/en/cli-lotus.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/en/cli-lotus.md b/documentation/en/cli-lotus.md index 0205ab2c0..751182a43 100644 --- a/documentation/en/cli-lotus.md +++ b/documentation/en/cli-lotus.md @@ -77,7 +77,7 @@ OPTIONS: --slash-consensus Report consensus fault (default: false) --slasher-sender value optionally specify the account to report consensus from --slashdb-dir value (default: "slash watch db dir path") - --help, -h show help (default: false) + --help, -h show help ``` ### lotus daemon stop From 48912e8f0922de5d648c73986bbca4fe53f43466 Mon Sep 17 00:00:00 2001 From: mx Date: Tue, 13 Jun 2023 09:46:36 +0800 Subject: [PATCH 8/8] fix: chain error --- chain/gen/slashfilter/slashfilter.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chain/gen/slashfilter/slashfilter.go b/chain/gen/slashfilter/slashfilter.go index 0d78be49e..0e6b00cfb 100644 --- a/chain/gen/slashfilter/slashfilter.go +++ b/chain/gen/slashfilter/slashfilter.go @@ -31,7 +31,7 @@ func (f *SlashFilter) MinedBlock(ctx context.Context, bh *types.BlockHeader, par { // double-fork mining (2 blocks at one epoch) if witness, err := checkFault(ctx, f.byEpoch, epochKey, bh, "double-fork mining faults"); err != nil { - return witness, err + return witness, xerrors.Errorf("check double-fork mining faults: %w", err) } } @@ -39,7 +39,7 @@ func (f *SlashFilter) MinedBlock(ctx context.Context, bh *types.BlockHeader, par { // time-offset mining faults (2 blocks with the same parents) if witness, err := checkFault(ctx, f.byParents, parentsKey, bh, "time-offset mining faults"); err != nil { - return witness, err + return witness, xerrors.Errorf("check time-offset mining faults: %w", err) } }