storage: Cleanup interfaces a bit
This commit is contained in:
parent
58416d0881
commit
db676acdf8
@ -43,6 +43,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/lib/sigs"
|
||||
"github.com/filecoin-project/lotus/metrics"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||
)
|
||||
|
||||
var log = logging.Logger("fil-consensus")
|
||||
@ -57,7 +58,7 @@ type FilecoinEC struct {
|
||||
// the state manager handles making state queries
|
||||
sm *stmgr.StateManager
|
||||
|
||||
verifier ffiwrapper.Verifier
|
||||
verifier storiface.Verifier
|
||||
|
||||
genesis *types.TipSet
|
||||
}
|
||||
@ -66,7 +67,7 @@ type FilecoinEC struct {
|
||||
// the theoretical max height based on systime are quickly rejected
|
||||
const MaxHeightDrift = 5
|
||||
|
||||
func NewFilecoinExpectedConsensus(sm *stmgr.StateManager, beacon beacon.Schedule, verifier ffiwrapper.Verifier, genesis chain.Genesis) consensus.Consensus {
|
||||
func NewFilecoinExpectedConsensus(sm *stmgr.StateManager, beacon beacon.Schedule, verifier storiface.Verifier, genesis chain.Genesis) consensus.Consensus {
|
||||
if build.InsecurePoStValidation {
|
||||
log.Warn("*********************************************************************************************")
|
||||
log.Warn(" [INSECURE-POST-VALIDATION] Insecure test validation is enabled. If you see this outside of a test, it is a severe bug! ")
|
||||
|
@ -44,6 +44,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/journal"
|
||||
"github.com/filecoin-project/lotus/node/repo"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||
)
|
||||
|
||||
const msgsPerBlock = 20
|
||||
@ -592,7 +593,7 @@ type MiningCheckAPI interface {
|
||||
type mca struct {
|
||||
w *wallet.LocalWallet
|
||||
sm *stmgr.StateManager
|
||||
pv ffiwrapper.Verifier
|
||||
pv storiface.Verifier
|
||||
bcn beacon.Schedule
|
||||
}
|
||||
|
||||
@ -674,7 +675,7 @@ func ComputeVRF(ctx context.Context, sign SignFunc, worker address.Address, sigI
|
||||
|
||||
type genFakeVerifier struct{}
|
||||
|
||||
var _ ffiwrapper.Verifier = (*genFakeVerifier)(nil)
|
||||
var _ storiface.Verifier = (*genFakeVerifier)(nil)
|
||||
|
||||
func (m genFakeVerifier) VerifySeal(svi proof7.SealVerifyInfo) (bool, error) {
|
||||
return true, nil
|
||||
|
@ -26,7 +26,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/chain/rand"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/chain/vm"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||
)
|
||||
|
||||
func GetMinerWorkerRaw(ctx context.Context, sm *StateManager, st cid.Cid, maddr address.Address) (address.Address, error) {
|
||||
@ -117,7 +117,7 @@ func MinerSectorInfo(ctx context.Context, sm *StateManager, maddr address.Addres
|
||||
return mas.GetSector(sid)
|
||||
}
|
||||
|
||||
func GetSectorsForWinningPoSt(ctx context.Context, nv network.Version, pv ffiwrapper.Verifier, sm *StateManager, st cid.Cid, maddr address.Address, rand abi.PoStRandomness) ([]builtin.ExtendedSectorInfo, error) {
|
||||
func GetSectorsForWinningPoSt(ctx context.Context, nv network.Version, pv storiface.Verifier, sm *StateManager, st cid.Cid, maddr address.Address, rand abi.PoStRandomness) ([]builtin.ExtendedSectorInfo, error) {
|
||||
act, err := sm.LoadActorRaw(ctx, maddr, st)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("failed to load miner actor: %w", err)
|
||||
@ -301,7 +301,7 @@ func ListMinerActors(ctx context.Context, sm *StateManager, ts *types.TipSet) ([
|
||||
return powState.ListAllMiners()
|
||||
}
|
||||
|
||||
func MinerGetBaseInfo(ctx context.Context, sm *StateManager, bcs beacon.Schedule, tsk types.TipSetKey, round abi.ChainEpoch, maddr address.Address, pv ffiwrapper.Verifier) (*api.MiningBaseInfo, error) {
|
||||
func MinerGetBaseInfo(ctx context.Context, sm *StateManager, bcs beacon.Schedule, tsk types.TipSetKey, round abi.ChainEpoch, maddr address.Address, pv storiface.Verifier) (*api.MiningBaseInfo, error) {
|
||||
ts, err := sm.ChainStore().LoadTipSet(ctx, tsk)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("failed to load tipset for mining base: %w", err)
|
||||
|
@ -28,6 +28,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/lib/sigs"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -38,7 +39,7 @@ func init() {
|
||||
|
||||
type SyscallBuilder func(ctx context.Context, rt *Runtime) runtime7.Syscalls
|
||||
|
||||
func Syscalls(verifier ffiwrapper.Verifier) SyscallBuilder {
|
||||
func Syscalls(verifier storiface.Verifier) SyscallBuilder {
|
||||
return func(ctx context.Context, rt *Runtime) runtime7.Syscalls {
|
||||
|
||||
return &syscallShim{
|
||||
@ -65,7 +66,7 @@ type syscallShim struct {
|
||||
actor address.Address
|
||||
cstate *state.StateTree
|
||||
cst cbor.IpldStore
|
||||
verifier ffiwrapper.Verifier
|
||||
verifier storiface.Verifier
|
||||
}
|
||||
|
||||
func (ss *syscallShim) ComputeUnsealedSectorCID(st abi.RegisteredSealProof, pieces []abi.PieceInfo) (cid.Cid, error) {
|
||||
|
@ -12,12 +12,12 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
prooftypes "github.com/filecoin-project/go-state-types/proof"
|
||||
|
||||
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||
)
|
||||
|
||||
type cachingVerifier struct {
|
||||
ds datastore.Datastore
|
||||
backend ffiwrapper.Verifier
|
||||
backend storiface.Verifier
|
||||
}
|
||||
|
||||
const bufsize = 128
|
||||
@ -107,4 +107,4 @@ func (cv cachingVerifier) VerifyReplicaUpdate(update prooftypes.ReplicaUpdateInf
|
||||
return cv.backend.VerifyReplicaUpdate(update)
|
||||
}
|
||||
|
||||
var _ ffiwrapper.Verifier = (*cachingVerifier)(nil)
|
||||
var _ storiface.Verifier = (*cachingVerifier)(nil)
|
||||
|
@ -44,6 +44,7 @@ import (
|
||||
_ "github.com/filecoin-project/lotus/lib/sigs/secp"
|
||||
"github.com/filecoin-project/lotus/node/repo"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||
)
|
||||
|
||||
type TipSetExec struct {
|
||||
@ -204,7 +205,7 @@ var importBenchCmd = &cli.Command{
|
||||
defer c.Close() //nolint:errcheck
|
||||
}
|
||||
|
||||
var verifier ffiwrapper.Verifier = ffiwrapper.ProofVerifier
|
||||
var verifier storiface.Verifier = ffiwrapper.ProofVerifier
|
||||
if cctx.IsSet("syscall-cache") {
|
||||
scds, err := badger.NewDatastore(cctx.String("syscall-cache"), &badger.DefaultOptions)
|
||||
if err != nil {
|
||||
|
@ -15,7 +15,7 @@ import (
|
||||
miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner"
|
||||
tutils "github.com/filecoin-project/specs-actors/v5/support/testing"
|
||||
|
||||
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||
)
|
||||
|
||||
// Ideally, we'd use extern/sealer/mock. Unfortunately, those mocks are a bit _too_ accurate
|
||||
@ -32,7 +32,7 @@ var log = logging.Logger("simulation-mock")
|
||||
// mockVerifier is a simple mock for verifying "fake" proofs.
|
||||
type mockVerifier struct{}
|
||||
|
||||
var Verifier ffiwrapper.Verifier = mockVerifier{}
|
||||
var Verifier storiface.Verifier = mockVerifier{}
|
||||
|
||||
func (mockVerifier) VerifySeal(proof prooftypes.SealVerifyInfo) (bool, error) {
|
||||
addr, err := address.NewIDAddress(uint64(proof.Miner))
|
||||
|
@ -57,8 +57,8 @@ import (
|
||||
"github.com/filecoin-project/lotus/node/repo"
|
||||
"github.com/filecoin-project/lotus/storage/paths"
|
||||
sectorstorage "github.com/filecoin-project/lotus/storage/sealer"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/mock"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -363,8 +363,8 @@ func (n *Ensemble) Start() *Ensemble {
|
||||
// Are we mocking proofs?
|
||||
if n.options.mockProofs {
|
||||
opts = append(opts,
|
||||
node.Override(new(ffiwrapper.Verifier), mock.MockVerifier),
|
||||
node.Override(new(ffiwrapper.Prover), mock.MockProver),
|
||||
node.Override(new(storiface.Verifier), mock.MockVerifier),
|
||||
node.Override(new(storiface.Prover), mock.MockProver),
|
||||
)
|
||||
}
|
||||
|
||||
@ -643,8 +643,8 @@ func (n *Ensemble) Start() *Ensemble {
|
||||
node.Override(new(sectorstorage.Unsealer), node.From(new(*mock.SectorMgr))),
|
||||
node.Override(new(sectorstorage.PieceProvider), node.From(new(*mock.SectorMgr))),
|
||||
|
||||
node.Override(new(ffiwrapper.Verifier), mock.MockVerifier),
|
||||
node.Override(new(ffiwrapper.Prover), mock.MockProver),
|
||||
node.Override(new(storiface.Verifier), mock.MockVerifier),
|
||||
node.Override(new(storiface.Prover), mock.MockProver),
|
||||
node.Unset(new(*sectorstorage.Manager)),
|
||||
)
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/paychmgr"
|
||||
"github.com/filecoin-project/lotus/paychmgr/settler"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||
)
|
||||
|
||||
// Chain node provides access to the Filecoin blockchain, by setting up a full
|
||||
@ -62,8 +63,8 @@ var ChainNode = Options(
|
||||
Override(new(dtypes.DrandBootstrap), modules.DrandBootstrap),
|
||||
|
||||
// Consensus: crypto dependencies
|
||||
Override(new(ffiwrapper.Verifier), ffiwrapper.ProofVerifier),
|
||||
Override(new(ffiwrapper.Prover), ffiwrapper.ProofProver),
|
||||
Override(new(storiface.Verifier), ffiwrapper.ProofVerifier),
|
||||
Override(new(storiface.Prover), ffiwrapper.ProofProver),
|
||||
|
||||
// Consensus: LegacyVM
|
||||
Override(new(vm.SyscallBuilder), vm.Syscalls),
|
||||
|
@ -101,9 +101,9 @@ func ConfigStorageMiner(c interface{}) Option {
|
||||
If(!cfg.Subsystems.EnableSectorStorage, Error(xerrors.Errorf("sealing can't be disabled on a mining node yet"))),
|
||||
|
||||
// Sector storage: Proofs
|
||||
Override(new(ffiwrapper.Verifier), ffiwrapper.ProofVerifier),
|
||||
Override(new(ffiwrapper.Prover), ffiwrapper.ProofProver),
|
||||
Override(new(storiface.Prover), From(new(sectorstorage.SectorManager))),
|
||||
Override(new(storiface.Verifier), ffiwrapper.ProofVerifier),
|
||||
Override(new(storiface.Prover), ffiwrapper.ProofProver),
|
||||
Override(new(storiface.ProverPoSt), From(new(sectorstorage.SectorManager))),
|
||||
|
||||
// Sealing (todo should be under EnableSealing, but storagefsm is currently bundled with storage.Miner)
|
||||
Override(new(sealing.SectorIDCounter), modules.SectorIDCounter),
|
||||
|
@ -45,7 +45,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/chain/vm"
|
||||
"github.com/filecoin-project/lotus/chain/wallet"
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||
)
|
||||
|
||||
type StateModuleAPI interface {
|
||||
@ -93,7 +93,7 @@ type StateAPI struct {
|
||||
|
||||
StateModuleAPI
|
||||
|
||||
ProofVerifier ffiwrapper.Verifier
|
||||
ProofVerifier storiface.Verifier
|
||||
StateManager *stmgr.StateManager
|
||||
Chain *store.ChainStore
|
||||
Beacon beacon.Schedule
|
||||
|
@ -70,7 +70,7 @@ import (
|
||||
sealing "github.com/filecoin-project/lotus/storage/pipeline"
|
||||
"github.com/filecoin-project/lotus/storage/pipeline/sealiface"
|
||||
"github.com/filecoin-project/lotus/storage/sealer"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||
"github.com/filecoin-project/lotus/storage/wdpost"
|
||||
)
|
||||
|
||||
@ -211,8 +211,8 @@ type StorageMinerParams struct {
|
||||
MetadataDS dtypes.MetadataDS
|
||||
Sealer sealer.SectorManager
|
||||
SectorIDCounter sealing.SectorIDCounter
|
||||
Verifier ffiwrapper.Verifier
|
||||
Prover ffiwrapper.Prover
|
||||
Verifier storiface.Verifier
|
||||
Prover storiface.Prover
|
||||
GetSealingConfigFn dtypes.GetSealingConfigFunc
|
||||
Journal journal.Journal
|
||||
AddrSel *ctladdr.AddressSelector
|
||||
|
@ -33,7 +33,6 @@ import (
|
||||
"github.com/filecoin-project/lotus/storage/ctladdr"
|
||||
pipeline "github.com/filecoin-project/lotus/storage/pipeline"
|
||||
"github.com/filecoin-project/lotus/storage/sealer"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||
)
|
||||
|
||||
@ -53,8 +52,8 @@ type Miner struct {
|
||||
sealer sealer.SectorManager
|
||||
ds datastore.Batching
|
||||
sc pipeline.SectorIDCounter
|
||||
verif ffiwrapper.Verifier
|
||||
prover ffiwrapper.Prover
|
||||
verif storiface.Verifier
|
||||
prover storiface.Prover
|
||||
addrSel *ctladdr.AddressSelector
|
||||
|
||||
maddr address.Address
|
||||
@ -136,8 +135,8 @@ func NewMiner(api fullNodeFilteredAPI,
|
||||
ds datastore.Batching,
|
||||
sealer sealer.SectorManager,
|
||||
sc pipeline.SectorIDCounter,
|
||||
verif ffiwrapper.Verifier,
|
||||
prover ffiwrapper.Prover,
|
||||
verif storiface.Verifier,
|
||||
prover storiface.Prover,
|
||||
gsd dtypes.GetSealingConfigFunc,
|
||||
feeCfg config.MinerFeeConfig,
|
||||
journal journal.Journal,
|
||||
@ -240,13 +239,13 @@ func (m *Miner) runPreflightChecks(ctx context.Context) error {
|
||||
}
|
||||
|
||||
type StorageWpp struct {
|
||||
prover storiface.Prover
|
||||
verifier ffiwrapper.Verifier
|
||||
prover storiface.ProverPoSt
|
||||
verifier storiface.Verifier
|
||||
miner abi.ActorID
|
||||
winnRpt abi.RegisteredPoStProof
|
||||
}
|
||||
|
||||
func NewWinningPoStProver(api v1api.FullNode, prover storiface.Prover, verifier ffiwrapper.Verifier, miner dtypes.MinerID) (*StorageWpp, error) {
|
||||
func NewWinningPoStProver(api v1api.FullNode, prover storiface.ProverPoSt, verifier storiface.Verifier, miner dtypes.MinerID) (*StorageWpp, error) {
|
||||
ma, err := address.NewIDAddress(uint64(miner))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -26,7 +26,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/node/config"
|
||||
"github.com/filecoin-project/lotus/storage/pipeline/sealiface"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||
)
|
||||
|
||||
var aggFeeNum = big.NewInt(110)
|
||||
@ -58,7 +58,7 @@ type CommitBatcher struct {
|
||||
addrSel AddrSel
|
||||
feeCfg config.MinerFeeConfig
|
||||
getConfig GetSealingConfigFunc
|
||||
prover ffiwrapper.Prover
|
||||
prover storiface.Prover
|
||||
|
||||
cutoffs map[abi.SectorNumber]time.Time
|
||||
todo map[abi.SectorNumber]AggregateInput
|
||||
@ -69,7 +69,7 @@ type CommitBatcher struct {
|
||||
lk sync.Mutex
|
||||
}
|
||||
|
||||
func NewCommitBatcher(mctx context.Context, maddr address.Address, api CommitBatcherApi, addrSel AddrSel, feeCfg config.MinerFeeConfig, getConfig GetSealingConfigFunc, prov ffiwrapper.Prover) *CommitBatcher {
|
||||
func NewCommitBatcher(mctx context.Context, maddr address.Address, api CommitBatcherApi, addrSel AddrSel, feeCfg config.MinerFeeConfig, getConfig GetSealingConfigFunc, prov storiface.Prover) *CommitBatcher {
|
||||
b := &CommitBatcher{
|
||||
api: api,
|
||||
maddr: maddr,
|
||||
|
@ -27,7 +27,7 @@ import (
|
||||
pipeline "github.com/filecoin-project/lotus/storage/pipeline"
|
||||
"github.com/filecoin-project/lotus/storage/pipeline/mocks"
|
||||
"github.com/filecoin-project/lotus/storage/pipeline/sealiface"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||
)
|
||||
|
||||
func TestCommitBatcher(t *testing.T) {
|
||||
@ -391,7 +391,7 @@ func (f fakeProver) AggregateSealProofs(aggregateInfo prooftypes.AggregateSealVe
|
||||
return []byte("Trust me, I'm a proof"), nil
|
||||
}
|
||||
|
||||
var _ ffiwrapper.Prover = &fakeProver{}
|
||||
var _ storiface.Prover = &fakeProver{}
|
||||
|
||||
var dummyAddr = func() address.Address {
|
||||
a, _ := address.NewFromString("t00")
|
||||
|
@ -27,7 +27,6 @@ import (
|
||||
"github.com/filecoin-project/lotus/node/config"
|
||||
"github.com/filecoin-project/lotus/storage/pipeline/sealiface"
|
||||
"github.com/filecoin-project/lotus/storage/sealer"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||
)
|
||||
|
||||
@ -88,7 +87,7 @@ type Sealing struct {
|
||||
sealer sealer.SectorManager
|
||||
sectors *statemachine.StateGroup
|
||||
sc SectorIDCounter
|
||||
verif ffiwrapper.Verifier
|
||||
verif storiface.Verifier
|
||||
pcp PreCommitPolicy
|
||||
|
||||
inputLk sync.Mutex
|
||||
@ -150,7 +149,7 @@ type pendingPiece struct {
|
||||
accepted func(abi.SectorNumber, abi.UnpaddedPieceSize, error)
|
||||
}
|
||||
|
||||
func New(mctx context.Context, api SealingAPI, fc config.MinerFeeConfig, events Events, maddr address.Address, ds datastore.Batching, sealer sealer.SectorManager, sc SectorIDCounter, verif ffiwrapper.Verifier, prov ffiwrapper.Prover, pcp PreCommitPolicy, gc GetSealingConfigFunc, notifee SectorStateNotifee, as AddrSel) *Sealing {
|
||||
func New(mctx context.Context, api SealingAPI, fc config.MinerFeeConfig, events Events, maddr address.Address, ds datastore.Batching, sealer sealer.SectorManager, sc SectorIDCounter, verif storiface.Verifier, prov storiface.Prover, pcp PreCommitPolicy, gc GetSealingConfigFunc, notifee SectorStateNotifee, as AddrSel) *Sealing {
|
||||
s := &Sealing{
|
||||
Api: api,
|
||||
DealInfo: &CurrentDealInfoManager{api},
|
||||
|
@ -6,11 +6,13 @@ package ffiwrapper
|
||||
import (
|
||||
ffi "github.com/filecoin-project/filecoin-ffi"
|
||||
"github.com/filecoin-project/go-state-types/proof"
|
||||
|
||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||
)
|
||||
|
||||
var ProofProver = proofProver{}
|
||||
|
||||
var _ Prover = ProofProver
|
||||
var _ storiface.Prover = ProofProver
|
||||
|
||||
type proofProver struct{}
|
||||
|
||||
|
@ -34,7 +34,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||
)
|
||||
|
||||
var _ Storage = &Sealer{}
|
||||
var _ storiface.Storage = &Sealer{}
|
||||
|
||||
func New(sectors SectorProvider) (*Sealer, error) {
|
||||
sb := &Sealer{
|
||||
|
@ -2,52 +2,11 @@ package ffiwrapper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/proof"
|
||||
|
||||
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper/basicfs"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||
)
|
||||
|
||||
type Validator interface {
|
||||
CanCommit(sector storiface.SectorPaths) (bool, error)
|
||||
CanProve(sector storiface.SectorPaths) (bool, error)
|
||||
}
|
||||
|
||||
type StorageSealer interface {
|
||||
storiface.Sealer
|
||||
storiface.Storage
|
||||
}
|
||||
|
||||
type Storage interface {
|
||||
storiface.Prover
|
||||
StorageSealer
|
||||
|
||||
UnsealPiece(ctx context.Context, sector storiface.SectorRef, offset storiface.UnpaddedByteIndex, size abi.UnpaddedPieceSize, randomness abi.SealRandomness, commd cid.Cid) error
|
||||
ReadPiece(ctx context.Context, writer io.Writer, sector storiface.SectorRef, offset storiface.UnpaddedByteIndex, size abi.UnpaddedPieceSize) (bool, error)
|
||||
}
|
||||
|
||||
type Verifier interface {
|
||||
VerifySeal(proof.SealVerifyInfo) (bool, error)
|
||||
VerifyAggregateSeals(aggregate proof.AggregateSealVerifyProofAndInfos) (bool, error)
|
||||
VerifyReplicaUpdate(update proof.ReplicaUpdateInfo) (bool, error)
|
||||
VerifyWinningPoSt(ctx context.Context, info proof.WinningPoStVerifyInfo) (bool, error)
|
||||
VerifyWindowPoSt(ctx context.Context, info proof.WindowPoStVerifyInfo) (bool, error)
|
||||
|
||||
GenerateWinningPoStSectorChallenge(context.Context, abi.RegisteredPoStProof, abi.ActorID, abi.PoStRandomness, uint64) ([]uint64, error)
|
||||
}
|
||||
|
||||
// Prover contains cheap proving-related methods
|
||||
type Prover interface {
|
||||
// TODO: move GenerateWinningPoStSectorChallenge from the Verifier interface to here
|
||||
|
||||
AggregateSealProofs(aggregateInfo proof.AggregateSealVerifyProofAndInfos, proofs [][]byte) ([]byte, error)
|
||||
}
|
||||
|
||||
type SectorProvider interface {
|
||||
// * returns storiface.ErrSectorNotFound if a requested existing sector doesn't exist
|
||||
// * returns an error when allocate is set, and existing isn't, and the sector exists
|
||||
|
@ -128,7 +128,7 @@ func (sb *Sealer) pubExtendedSectorToPriv(ctx context.Context, mid abi.ActorID,
|
||||
return ffi.NewSortedPrivateSectorInfo(out...), skipped, done, nil
|
||||
}
|
||||
|
||||
var _ Verifier = ProofVerifier
|
||||
var _ storiface.Verifier = ProofVerifier
|
||||
|
||||
type proofVerifier struct{}
|
||||
|
||||
|
@ -45,8 +45,8 @@ type Worker interface {
|
||||
}
|
||||
|
||||
type SectorManager interface {
|
||||
ffiwrapper.StorageSealer
|
||||
storiface.Prover
|
||||
storiface.Sealer
|
||||
storiface.ProverPoSt
|
||||
storiface.WorkerReturn
|
||||
FaultTracker
|
||||
}
|
||||
@ -64,7 +64,7 @@ type Manager struct {
|
||||
windowPoStSched *poStScheduler
|
||||
winningPoStSched *poStScheduler
|
||||
|
||||
localProver storiface.Prover
|
||||
localProver storiface.ProverPoSt
|
||||
|
||||
workLk sync.Mutex
|
||||
work *statestore.StateStore
|
||||
@ -80,7 +80,7 @@ type Manager struct {
|
||||
waitRes map[WorkID]chan struct{}
|
||||
}
|
||||
|
||||
var _ storiface.Prover = &Manager{}
|
||||
var _ storiface.ProverPoSt = &Manager{}
|
||||
|
||||
type result struct {
|
||||
r interface{}
|
||||
|
@ -635,7 +635,7 @@ func TestRestartWorker(t *testing.T) {
|
||||
wds := datastore.NewMapDatastore()
|
||||
|
||||
arch := make(chan chan apres)
|
||||
w := newLocalWorker(func() (ffiwrapper.Storage, error) {
|
||||
w := newLocalWorker(func() (storiface.Storage, error) {
|
||||
return &testExec{apch: arch}, nil
|
||||
}, WorkerConfig{
|
||||
TaskTypes: localTasks,
|
||||
@ -672,7 +672,7 @@ func TestRestartWorker(t *testing.T) {
|
||||
}
|
||||
|
||||
// restart the worker
|
||||
w = newLocalWorker(func() (ffiwrapper.Storage, error) {
|
||||
w = newLocalWorker(func() (storiface.Storage, error) {
|
||||
return &testExec{apch: arch}, nil
|
||||
}, WorkerConfig{
|
||||
TaskTypes: localTasks,
|
||||
@ -708,7 +708,7 @@ func TestReenableWorker(t *testing.T) {
|
||||
wds := datastore.NewMapDatastore()
|
||||
|
||||
arch := make(chan chan apres)
|
||||
w := newLocalWorker(func() (ffiwrapper.Storage, error) {
|
||||
w := newLocalWorker(func() (storiface.Storage, error) {
|
||||
return &testExec{apch: arch}, nil
|
||||
}, WorkerConfig{
|
||||
TaskTypes: localTasks,
|
||||
@ -781,7 +781,7 @@ func TestResUse(t *testing.T) {
|
||||
wds := datastore.NewMapDatastore()
|
||||
|
||||
arch := make(chan chan apres)
|
||||
w := newLocalWorker(func() (ffiwrapper.Storage, error) {
|
||||
w := newLocalWorker(func() (storiface.Storage, error) {
|
||||
return &testExec{apch: arch}, nil
|
||||
}, WorkerConfig{
|
||||
TaskTypes: localTasks,
|
||||
@ -839,7 +839,7 @@ func TestResOverride(t *testing.T) {
|
||||
wds := datastore.NewMapDatastore()
|
||||
|
||||
arch := make(chan chan apres)
|
||||
w := newLocalWorker(func() (ffiwrapper.Storage, error) {
|
||||
w := newLocalWorker(func() (storiface.Storage, error) {
|
||||
return &testExec{apch: arch}, nil
|
||||
}, WorkerConfig{
|
||||
TaskTypes: localTasks,
|
||||
|
@ -735,5 +735,5 @@ var MockVerifier = mockVerifProver{
|
||||
var MockProver = MockVerifier
|
||||
|
||||
var _ storiface.Sealer = &SectorMgr{}
|
||||
var _ ffiwrapper.Verifier = MockVerifier
|
||||
var _ ffiwrapper.Prover = MockProver
|
||||
var _ storiface.Verifier = MockVerifier
|
||||
var _ storiface.Prover = MockProver
|
||||
|
@ -19,17 +19,7 @@ type SectorRef struct {
|
||||
|
||||
var NoSectorRef = SectorRef{}
|
||||
|
||||
type Storage interface {
|
||||
// Creates a new empty sector (only allocate on disk. Layers above
|
||||
// storage are responsible for assigning sector IDs)
|
||||
NewSector(ctx context.Context, sector SectorRef) error
|
||||
// Compute Data CID
|
||||
DataCid(ctx context.Context, pieceSize abi.UnpaddedPieceSize, pieceData Data) (abi.PieceInfo, error)
|
||||
// Add a piece to an existing *unsealed* sector
|
||||
AddPiece(ctx context.Context, sector SectorRef, pieceSizes []abi.UnpaddedPieceSize, newPieceSize abi.UnpaddedPieceSize, pieceData Data) (abi.PieceInfo, error)
|
||||
}
|
||||
|
||||
type Prover interface {
|
||||
type ProverPoSt interface {
|
||||
GenerateWinningPoSt(ctx context.Context, minerID abi.ActorID, sectorInfo []proof.ExtendedSectorInfo, randomness abi.PoStRandomness) ([]proof.PoStProof, error)
|
||||
GenerateWindowPoSt(ctx context.Context, minerID abi.ActorID, sectorInfo []proof.ExtendedSectorInfo, randomness abi.PoStRandomness) (proof []proof.PoStProof, skipped []abi.SectorID, err error)
|
||||
|
||||
@ -62,6 +52,10 @@ type ReplicaUpdateOut struct {
|
||||
}
|
||||
|
||||
type Sealer interface {
|
||||
NewSector(ctx context.Context, sector SectorRef) error
|
||||
DataCid(ctx context.Context, pieceSize abi.UnpaddedPieceSize, pieceData Data) (abi.PieceInfo, error)
|
||||
AddPiece(ctx context.Context, sector SectorRef, pieceSizes []abi.UnpaddedPieceSize, newPieceSize abi.UnpaddedPieceSize, pieceData Data) (abi.PieceInfo, error)
|
||||
|
||||
SealPreCommit1(ctx context.Context, sector SectorRef, ticket abi.SealRandomness, pieces []abi.PieceInfo) (PreCommit1Out, error)
|
||||
SealPreCommit2(ctx context.Context, sector SectorRef, pc1o PreCommit1Out) (SectorCids, error)
|
||||
|
||||
@ -92,3 +86,36 @@ type Sealer interface {
|
||||
|
||||
FinalizeReplicaUpdate(ctx context.Context, sector SectorRef, keepUnsealed []Range) error
|
||||
}
|
||||
|
||||
type Unsealer interface {
|
||||
UnsealPiece(ctx context.Context, sector SectorRef, offset UnpaddedByteIndex, size abi.UnpaddedPieceSize, randomness abi.SealRandomness, commd cid.Cid) error
|
||||
ReadPiece(ctx context.Context, writer io.Writer, sector SectorRef, offset UnpaddedByteIndex, size abi.UnpaddedPieceSize) (bool, error)
|
||||
}
|
||||
|
||||
type Storage interface {
|
||||
ProverPoSt
|
||||
Sealer
|
||||
Unsealer
|
||||
}
|
||||
|
||||
type Validator interface {
|
||||
CanCommit(sector SectorPaths) (bool, error)
|
||||
CanProve(sector SectorPaths) (bool, error)
|
||||
}
|
||||
|
||||
type Verifier interface {
|
||||
VerifySeal(proof.SealVerifyInfo) (bool, error)
|
||||
VerifyAggregateSeals(aggregate proof.AggregateSealVerifyProofAndInfos) (bool, error)
|
||||
VerifyReplicaUpdate(update proof.ReplicaUpdateInfo) (bool, error)
|
||||
VerifyWinningPoSt(ctx context.Context, info proof.WinningPoStVerifyInfo) (bool, error)
|
||||
VerifyWindowPoSt(ctx context.Context, info proof.WindowPoStVerifyInfo) (bool, error)
|
||||
|
||||
GenerateWinningPoStSectorChallenge(context.Context, abi.RegisteredPoStProof, abi.ActorID, abi.PoStRandomness, uint64) ([]uint64, error)
|
||||
}
|
||||
|
||||
// Prover contains cheap proving-related methods
|
||||
type Prover interface {
|
||||
// TODO: move GenerateWinningPoStSectorChallenge from the Verifier interface to here
|
||||
|
||||
AggregateSealProofs(aggregateInfo proof.AggregateSealVerifyProofAndInfos, proofs [][]byte) ([]byte, error)
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/specs-actors/v7/actors/runtime/proof"
|
||||
|
||||
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||
)
|
||||
|
||||
@ -121,4 +120,4 @@ func (t *testExec) ReadPiece(ctx context.Context, writer io.Writer, sector stori
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
var _ ffiwrapper.Storage = &testExec{}
|
||||
var _ storiface.Storage = &testExec{}
|
||||
|
@ -44,7 +44,7 @@ type WorkerConfig struct {
|
||||
}
|
||||
|
||||
// used do provide custom proofs impl (mostly used in testing)
|
||||
type ExecutorFunc func() (ffiwrapper.Storage, error)
|
||||
type ExecutorFunc func() (storiface.Storage, error)
|
||||
type EnvFunc func(string) (string, bool)
|
||||
|
||||
type LocalWorker struct {
|
||||
@ -172,7 +172,7 @@ func (l *localWorkerPathProvider) AcquireSector(ctx context.Context, sector stor
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (l *LocalWorker) ffiExec() (ffiwrapper.Storage, error) {
|
||||
func (l *LocalWorker) ffiExec() (storiface.Storage, error) {
|
||||
return ffiwrapper.New(&localWorkerPathProvider{w: l})
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,6 @@ import (
|
||||
"github.com/filecoin-project/lotus/node/config"
|
||||
"github.com/filecoin-project/lotus/storage/ctladdr"
|
||||
"github.com/filecoin-project/lotus/storage/sealer"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||
)
|
||||
|
||||
@ -66,8 +65,8 @@ type WindowPoStScheduler struct {
|
||||
api NodeAPI
|
||||
feeCfg config.MinerFeeConfig
|
||||
addrSel *ctladdr.AddressSelector
|
||||
prover storiface.Prover
|
||||
verifier ffiwrapper.Verifier
|
||||
prover storiface.ProverPoSt
|
||||
verifier storiface.Verifier
|
||||
faultTracker sealer.FaultTracker
|
||||
proofType abi.RegisteredPoStProof
|
||||
partitionSectors uint64
|
||||
@ -86,8 +85,8 @@ type WindowPoStScheduler struct {
|
||||
func NewWindowedPoStScheduler(api NodeAPI,
|
||||
cfg config.MinerFeeConfig,
|
||||
as *ctladdr.AddressSelector,
|
||||
sp storiface.Prover,
|
||||
verif ffiwrapper.Verifier,
|
||||
sp storiface.ProverPoSt,
|
||||
verif storiface.Verifier,
|
||||
ft sealer.FaultTracker,
|
||||
j journal.Journal,
|
||||
actor address.Address) (*WindowPoStScheduler, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user