diff --git a/chain/gen/slashfilter/slashfilter.go b/chain/gen/slashfilter/slashfilter.go index e5a0de63e..ce1518e10 100644 --- a/chain/gen/slashfilter/slashfilter.go +++ b/chain/gen/slashfilter/slashfilter.go @@ -14,7 +14,7 @@ import ( ) type SlashFilter struct { - byEpoch ds.Datastore // double-fork mining faults, parent-grinding fault + byEpoch ds.Datastore // double-fork mining faults, parent-grinding fault byParents ds.Datastore // time-offset mining faults } diff --git a/chain/sync_test.go b/chain/sync_test.go index 451ba1959..cf29023e6 100644 --- a/chain/sync_test.go +++ b/chain/sync_test.go @@ -7,6 +7,7 @@ import ( "testing" "time" + ds "github.com/ipfs/go-datastore" logging "github.com/ipfs/go-log/v2" "github.com/libp2p/go-libp2p-core/peer" mocknet "github.com/libp2p/go-libp2p/p2p/net/mock" @@ -22,6 +23,7 @@ import ( "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/gen" + "github.com/filecoin-project/lotus/chain/gen/slashfilter" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" mocktypes "github.com/filecoin-project/lotus/chain/types/mock" @@ -419,6 +421,8 @@ func TestSyncBadTimestamp(t *testing.T) { tu.g.Timestamper = nil require.NoError(t, tu.g.ResyncBankerNonce(a1.TipSet())) + tu.nds[0].(*impl.FullNodeAPI).SlashFilter = slashfilter.New(ds.NewMapDatastore()) + fmt.Println("After mine bad block!") tu.printHeads() a2 := tu.mineOnBlock(base, 0, nil, true, false) diff --git a/miner/miner.go b/miner/miner.go index 59110f384..8857b50f4 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -62,7 +62,7 @@ func NewMiner(api api.FullNode, epp gen.WinningPoStProver, addr address.Address, return func(bool, error) {}, 0, nil }, - sf: sf, + sf: sf, minedBlockHeights: arc, } } @@ -81,7 +81,7 @@ type Miner struct { lastWork *MiningBase - sf *slashfilter.SlashFilter + sf *slashfilter.SlashFilter minedBlockHeights *lru.ARCCache } diff --git a/miner/testminer.go b/miner/testminer.go index 92856219c..f5c7243e8 100644 --- a/miner/testminer.go +++ b/miner/testminer.go @@ -3,11 +3,14 @@ package miner import ( "context" + lru "github.com/hashicorp/golang-lru" + ds "github.com/ipfs/go-datastore" + "github.com/filecoin-project/go-address" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/chain/gen" + "github.com/filecoin-project/lotus/chain/gen/slashfilter" "github.com/filecoin-project/specs-actors/actors/abi" - lru "github.com/hashicorp/golang-lru" ) type MineReq struct { @@ -28,6 +31,7 @@ func NewTestMiner(nextCh <-chan MineReq, addr address.Address) func(api.FullNode epp: epp, minedBlockHeights: arc, address: addr, + sf: slashfilter.New(ds.NewMapDatastore()), } if err := m.Start(context.TODO()); err != nil { diff --git a/node/builder.go b/node/builder.go index aef0088ac..8e800c2b5 100644 --- a/node/builder.go +++ b/node/builder.go @@ -3,8 +3,6 @@ package node import ( "context" "errors" - "github.com/filecoin-project/lotus/chain/gen/slashfilter" - "github.com/filecoin-project/lotus/markets/dealfilter" "time" logging "github.com/ipfs/go-log" @@ -33,6 +31,7 @@ import ( "github.com/filecoin-project/lotus/chain/beacon" "github.com/filecoin-project/lotus/chain/blocksync" "github.com/filecoin-project/lotus/chain/gen" + "github.com/filecoin-project/lotus/chain/gen/slashfilter" "github.com/filecoin-project/lotus/chain/market" "github.com/filecoin-project/lotus/chain/messagepool" "github.com/filecoin-project/lotus/chain/metrics" @@ -45,6 +44,7 @@ import ( "github.com/filecoin-project/lotus/lib/peermgr" _ "github.com/filecoin-project/lotus/lib/sigs/bls" _ "github.com/filecoin-project/lotus/lib/sigs/secp" + "github.com/filecoin-project/lotus/markets/dealfilter" "github.com/filecoin-project/lotus/markets/storageadapter" "github.com/filecoin-project/lotus/miner" "github.com/filecoin-project/lotus/node/config" diff --git a/node/impl/full/sync.go b/node/impl/full/sync.go index e9a15319e..758ecb34d 100644 --- a/node/impl/full/sync.go +++ b/node/impl/full/sync.go @@ -2,7 +2,6 @@ package full import ( "context" - "github.com/filecoin-project/lotus/chain/gen/slashfilter" cid "github.com/ipfs/go-cid" pubsub "github.com/libp2p/go-libp2p-pubsub" @@ -12,6 +11,7 @@ import ( "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain" + "github.com/filecoin-project/lotus/chain/gen/slashfilter" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/node/modules/dtypes" ) @@ -20,9 +20,9 @@ type SyncAPI struct { fx.In SlashFilter *slashfilter.SlashFilter - Syncer *chain.Syncer - PubSub *pubsub.PubSub - NetName dtypes.NetworkName + Syncer *chain.Syncer + PubSub *pubsub.PubSub + NetName dtypes.NetworkName } func (a *SyncAPI) SyncState(ctx context.Context) (*api.SyncState, error) { diff --git a/node/modules/chain.go b/node/modules/chain.go index ac16a738c..904c9f23b 100644 --- a/node/modules/chain.go +++ b/node/modules/chain.go @@ -3,7 +3,6 @@ package modules import ( "bytes" "context" - "github.com/filecoin-project/lotus/chain/gen/slashfilter" "github.com/ipfs/go-bitswap" "github.com/ipfs/go-bitswap/network" @@ -21,6 +20,7 @@ import ( "github.com/filecoin-project/lotus/chain" "github.com/filecoin-project/lotus/chain/beacon" "github.com/filecoin-project/lotus/chain/blocksync" + "github.com/filecoin-project/lotus/chain/gen/slashfilter" "github.com/filecoin-project/lotus/chain/messagepool" "github.com/filecoin-project/lotus/chain/stmgr" "github.com/filecoin-project/lotus/chain/store" diff --git a/node/modules/storageminer.go b/node/modules/storageminer.go index 90013864e..a0956d31c 100644 --- a/node/modules/storageminer.go +++ b/node/modules/storageminer.go @@ -4,8 +4,6 @@ import ( "context" "errors" "fmt" - "github.com/filecoin-project/go-fil-markets/storagemarket/impl/funds" - "github.com/filecoin-project/lotus/chain/gen/slashfilter" "net/http" "time" @@ -37,6 +35,7 @@ import ( rmnet "github.com/filecoin-project/go-fil-markets/retrievalmarket/network" "github.com/filecoin-project/go-fil-markets/storagemarket" storageimpl "github.com/filecoin-project/go-fil-markets/storagemarket/impl" + "github.com/filecoin-project/go-fil-markets/storagemarket/impl/funds" "github.com/filecoin-project/go-fil-markets/storagemarket/impl/requestvalidation" "github.com/filecoin-project/go-fil-markets/storagemarket/impl/storedask" smnet "github.com/filecoin-project/go-fil-markets/storagemarket/network" @@ -54,6 +53,7 @@ import ( lapi "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/gen" + "github.com/filecoin-project/lotus/chain/gen/slashfilter" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/lib/blockstore" marketevents "github.com/filecoin-project/lotus/markets/loggers" diff --git a/node/repo/fsrepo_ds.go b/node/repo/fsrepo_ds.go index 9da7210cc..e62fe17e4 100644 --- a/node/repo/fsrepo_ds.go +++ b/node/repo/fsrepo_ds.go @@ -37,8 +37,8 @@ func badgerDs(path string) (datastore.Batching, error) { func levelDs(path string) (datastore.Batching, error) { return levelds.NewDatastore(path, &levelds.Options{ Compression: ldbopts.NoCompression, - NoSync: false, - Strict: ldbopts.StrictAll, + NoSync: false, + Strict: ldbopts.StrictAll, }) }