Skip to content

Commit

Permalink
storage: Cleanup interfaces a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Jun 17, 2022
1 parent 58416d0 commit db676ac
Show file tree
Hide file tree
Showing 27 changed files with 110 additions and 121 deletions.
5 changes: 3 additions & 2 deletions chain/consensus/filcns/filecoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
}
Expand All @@ -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! ")
Expand Down
5 changes: 3 additions & 2 deletions chain/gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions chain/stmgr/actors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions chain/vm/syscalls.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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{
Expand All @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions cmd/lotus-bench/caching_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
3 changes: 2 additions & 1 deletion cmd/lotus-bench/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions cmd/lotus-sim/simulation/mock/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand Down
10 changes: 5 additions & 5 deletions itests/kit/ensemble.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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),
)
}

Expand Down Expand Up @@ -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)),
)
}
Expand Down
5 changes: 3 additions & 2 deletions node/builder_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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),
Expand Down
6 changes: 3 additions & 3 deletions node/builder_miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions node/impl/full/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -93,7 +93,7 @@ type StateAPI struct {

StateModuleAPI

ProofVerifier ffiwrapper.Verifier
ProofVerifier storiface.Verifier
StateManager *stmgr.StateManager
Chain *store.ChainStore
Beacon beacon.Schedule
Expand Down
6 changes: 3 additions & 3 deletions node/modules/storageminer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
Expand Down
15 changes: 7 additions & 8 deletions storage/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions storage/pipeline/commit_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions storage/pipeline/commit_batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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")
Expand Down
5 changes: 2 additions & 3 deletions storage/pipeline/sealing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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},
Expand Down
4 changes: 3 additions & 1 deletion storage/sealer/ffiwrapper/prover_cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}

Expand Down
Loading

0 comments on commit db676ac

Please sign in to comment.