storage: Move window-post logic into a separate package
This commit is contained in:
parent
12c91bb41d
commit
dff1bf2868
@ -24,7 +24,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/node"
|
||||
"github.com/filecoin-project/lotus/node/impl"
|
||||
"github.com/filecoin-project/lotus/node/repo"
|
||||
"github.com/filecoin-project/lotus/storage"
|
||||
"github.com/filecoin-project/lotus/storage/wdpost"
|
||||
)
|
||||
|
||||
func TestWorkerPledge(t *testing.T) {
|
||||
@ -145,7 +145,7 @@ func TestWindowPostWorker(t *testing.T) {
|
||||
di = di.NextNotElapsed()
|
||||
|
||||
t.Log("Running one proving period")
|
||||
waitUntil := di.Open + di.WPoStChallengeWindow*2 + storage.SubmitConfidence
|
||||
waitUntil := di.Open + di.WPoStChallengeWindow*2 + wdpost.SubmitConfidence
|
||||
client.WaitTillChain(ctx, kit.HeightAtLeast(waitUntil))
|
||||
|
||||
t.Log("Waiting for post message")
|
||||
@ -284,7 +284,7 @@ func TestWindowPostWorkerSkipBadSector(t *testing.T) {
|
||||
di = di.NextNotElapsed()
|
||||
|
||||
t.Log("Running one proving period")
|
||||
waitUntil := di.Open + di.WPoStChallengeWindow*2 + storage.SubmitConfidence
|
||||
waitUntil := di.Open + di.WPoStChallengeWindow*2 + wdpost.SubmitConfidence
|
||||
client.WaitTillChain(ctx, kit.HeightAtLeast(waitUntil))
|
||||
|
||||
t.Log("Waiting for post message")
|
||||
|
@ -38,6 +38,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/node/repo"
|
||||
"github.com/filecoin-project/lotus/storage"
|
||||
"github.com/filecoin-project/lotus/storage/sectorblocks"
|
||||
"github.com/filecoin-project/lotus/storage/wdpost"
|
||||
)
|
||||
|
||||
var MinerNode = Options(
|
||||
@ -116,7 +117,7 @@ func ConfigStorageMiner(c interface{}) Option {
|
||||
Override(new(*miner.Miner), modules.SetupBlockProducer),
|
||||
Override(new(gen.WinningPoStProver), storage.NewWinningPoStProver),
|
||||
Override(new(*storage.Miner), modules.StorageMiner(cfg.Fees)),
|
||||
Override(new(*storage.WindowPoStScheduler), modules.WindowPostScheduler(cfg.Fees)),
|
||||
Override(new(*wdpost.WindowPoStScheduler), modules.WindowPostScheduler(cfg.Fees)),
|
||||
Override(new(sectorblocks.SectorBuilder), From(new(*storage.Miner))),
|
||||
),
|
||||
|
||||
|
@ -54,6 +54,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
"github.com/filecoin-project/lotus/storage"
|
||||
"github.com/filecoin-project/lotus/storage/sectorblocks"
|
||||
"github.com/filecoin-project/lotus/storage/wdpost"
|
||||
)
|
||||
|
||||
type StorageMinerAPI struct {
|
||||
@ -91,7 +92,7 @@ type StorageMinerAPI struct {
|
||||
storiface.WorkerReturn `optional:"true"`
|
||||
AddrSel *storage.AddressSelector
|
||||
|
||||
WdPoSt *storage.WindowPoStScheduler `optional:"true"`
|
||||
WdPoSt *wdpost.WindowPoStScheduler `optional:"true"`
|
||||
|
||||
Epp gen.WinningPoStProver `optional:"true"`
|
||||
DS dtypes.MetadataDS
|
||||
|
@ -70,6 +70,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/node/modules/helpers"
|
||||
"github.com/filecoin-project/lotus/node/repo"
|
||||
"github.com/filecoin-project/lotus/storage"
|
||||
"github.com/filecoin-project/lotus/storage/wdpost"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -252,8 +253,8 @@ func StorageMiner(fc config.MinerFeeConfig) func(params StorageMinerParams) (*st
|
||||
}
|
||||
}
|
||||
|
||||
func WindowPostScheduler(fc config.MinerFeeConfig) func(params StorageMinerParams) (*storage.WindowPoStScheduler, error) {
|
||||
return func(params StorageMinerParams) (*storage.WindowPoStScheduler, error) {
|
||||
func WindowPostScheduler(fc config.MinerFeeConfig) func(params StorageMinerParams) (*wdpost.WindowPoStScheduler, error) {
|
||||
return func(params StorageMinerParams) (*wdpost.WindowPoStScheduler, error) {
|
||||
var (
|
||||
mctx = params.MetricsCtx
|
||||
lc = params.Lifecycle
|
||||
@ -267,7 +268,7 @@ func WindowPostScheduler(fc config.MinerFeeConfig) func(params StorageMinerParam
|
||||
|
||||
ctx := helpers.LifecycleCtx(mctx, lc)
|
||||
|
||||
fps, err := storage.NewWindowedPoStScheduler(api, fc, as, sealer, verif, sealer, j, maddr)
|
||||
fps, err := wdpost.NewWindowedPoStScheduler(api, fc, as, sealer, verif, sealer, j, maddr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package storage
|
||||
package wdpost
|
||||
|
||||
import (
|
||||
"context"
|
@ -1,5 +1,5 @@
|
||||
//stm: #unit
|
||||
package storage
|
||||
package wdpost
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -117,7 +117,7 @@ func (m *mockAPI) startGeneratePoST(
|
||||
completeGeneratePoST CompleteGeneratePoSTCb,
|
||||
) context.CancelFunc {
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
log.Errorf("mock posting\n")
|
||||
storage.log.Errorf("mock posting\n")
|
||||
m.statesLk.Lock()
|
||||
defer m.statesLk.Unlock()
|
||||
m.postStates[deadline.Open] = postStatusProving
|
@ -1,4 +1,4 @@
|
||||
package storage
|
||||
package wdpost
|
||||
|
||||
import (
|
||||
"github.com/ipfs/go-cid"
|
@ -1,5 +1,5 @@
|
||||
//stm: #unit
|
||||
package storage
|
||||
package wdpost
|
||||
|
||||
import (
|
||||
"testing"
|
@ -1,4 +1,4 @@
|
||||
package storage
|
||||
package wdpost
|
||||
|
||||
import (
|
||||
"bytes"
|
@ -1,5 +1,5 @@
|
||||
//stm: #unit
|
||||
package storage
|
||||
package wdpost
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@ -32,12 +32,13 @@ import (
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
|
||||
"github.com/filecoin-project/lotus/journal"
|
||||
storage2 "github.com/filecoin-project/lotus/storage"
|
||||
)
|
||||
|
||||
type mockStorageMinerAPI struct {
|
||||
partitions []api.Partition
|
||||
pushedMessages chan *types.Message
|
||||
fullNodeFilteredAPI
|
||||
storage2.fullNodeFilteredAPI
|
||||
}
|
||||
|
||||
func newMockStorageMinerAPI() *mockStorageMinerAPI {
|
||||
@ -236,7 +237,7 @@ func TestWDPostDoPost(t *testing.T) {
|
||||
proofType: proofType,
|
||||
actor: postAct,
|
||||
journal: journal.NilJournal(),
|
||||
addrSel: &AddressSelector{},
|
||||
addrSel: &storage2.AddressSelector{},
|
||||
}
|
||||
|
||||
di := &dline.Info{
|
||||
@ -419,4 +420,4 @@ func (m *mockStorageMinerAPI) WalletHas(ctx context.Context, address address.Add
|
||||
return true, nil
|
||||
}
|
||||
|
||||
var _ fullNodeFilteredAPI = &mockStorageMinerAPI{}
|
||||
var _ storage2.fullNodeFilteredAPI = &mockStorageMinerAPI{}
|
@ -1,15 +1,21 @@
|
||||
package storage
|
||||
package wdpost
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
"go.opencensus.io/trace"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-bitfield"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/builtin/v8/miner"
|
||||
"github.com/filecoin-project/go-state-types/crypto"
|
||||
"github.com/filecoin-project/go-state-types/dline"
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
"github.com/filecoin-project/specs-storage/storage"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
@ -20,8 +26,36 @@ import (
|
||||
"github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper"
|
||||
"github.com/filecoin-project/lotus/journal"
|
||||
"github.com/filecoin-project/lotus/node/config"
|
||||
storage2 "github.com/filecoin-project/lotus/storage"
|
||||
)
|
||||
|
||||
var log = logging.Logger("wdpost")
|
||||
|
||||
type NodeAPI interface {
|
||||
ChainHead(context.Context) (*types.TipSet, error)
|
||||
ChainNotify(context.Context) (<-chan []*api.HeadChange, error)
|
||||
|
||||
StateMinerInfo(context.Context, address.Address, types.TipSetKey) (api.MinerInfo, error)
|
||||
StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*dline.Info, error)
|
||||
StateMinerSectors(context.Context, address.Address, *bitfield.BitField, types.TipSetKey) ([]*miner.SectorOnChainInfo, error)
|
||||
StateNetworkVersion(context.Context, types.TipSetKey) (network.Version, error)
|
||||
StateGetRandomnessFromTickets(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, tsk types.TipSetKey) (abi.Randomness, error)
|
||||
StateGetRandomnessFromBeacon(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, tsk types.TipSetKey) (abi.Randomness, error)
|
||||
StateWaitMsg(ctx context.Context, cid cid.Cid, confidence uint64, limit abi.ChainEpoch, allowReplaced bool) (*api.MsgLookup, error)
|
||||
StateMinerPartitions(context.Context, address.Address, uint64, types.TipSetKey) ([]api.Partition, error)
|
||||
StateLookupID(context.Context, address.Address, types.TipSetKey) (address.Address, error)
|
||||
StateAccountKey(context.Context, address.Address, types.TipSetKey) (address.Address, error)
|
||||
|
||||
MpoolPushMessage(context.Context, *types.Message, *api.MessageSendSpec) (*types.SignedMessage, error)
|
||||
|
||||
GasEstimateMessageGas(context.Context, *types.Message, *api.MessageSendSpec, types.TipSetKey) (*types.Message, error)
|
||||
GasEstimateFeeCap(context.Context, *types.Message, int64, types.TipSetKey) (types.BigInt, error)
|
||||
GasEstimateGasPremium(_ context.Context, nblocksincl uint64, sender address.Address, gaslimit int64, tsk types.TipSetKey) (types.BigInt, error)
|
||||
|
||||
WalletBalance(context.Context, address.Address) (types.BigInt, error)
|
||||
WalletHas(context.Context, address.Address) (bool, error)
|
||||
}
|
||||
|
||||
// WindowPoStScheduler is the coordinator for WindowPoSt submissions, fault
|
||||
// declaration, and recovery declarations. It watches the chain for reverts and
|
||||
// applies, and schedules/run those processes as partition deadlines arrive.
|
||||
@ -29,9 +63,9 @@ import (
|
||||
// WindowPoStScheduler watches the chain though the changeHandler, which in turn
|
||||
// turn calls the scheduler when the time arrives to do work.
|
||||
type WindowPoStScheduler struct {
|
||||
api fullNodeFilteredAPI
|
||||
api NodeAPI
|
||||
feeCfg config.MinerFeeConfig
|
||||
addrSel *AddressSelector
|
||||
addrSel *storage2.AddressSelector
|
||||
prover storage.Prover
|
||||
verifier ffiwrapper.Verifier
|
||||
faultTracker sectorstorage.FaultTracker
|
||||
@ -49,9 +83,9 @@ type WindowPoStScheduler struct {
|
||||
}
|
||||
|
||||
// NewWindowedPoStScheduler creates a new WindowPoStScheduler scheduler.
|
||||
func NewWindowedPoStScheduler(api fullNodeFilteredAPI,
|
||||
func NewWindowedPoStScheduler(api NodeAPI,
|
||||
cfg config.MinerFeeConfig,
|
||||
as *AddressSelector,
|
||||
as *storage2.AddressSelector,
|
||||
sp storage.Prover,
|
||||
verif ffiwrapper.Verifier,
|
||||
ft sectorstorage.FaultTracker,
|
||||
@ -88,7 +122,7 @@ func (s *WindowPoStScheduler) Run(ctx context.Context) {
|
||||
|
||||
// callbacks is a union of the fullNodeFilteredAPI and ourselves.
|
||||
callbacks := struct {
|
||||
fullNodeFilteredAPI
|
||||
NodeAPI
|
||||
*WindowPoStScheduler
|
||||
}{s.api, s}
|
||||
|
Loading…
Reference in New Issue
Block a user