Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to configure the proof type at runtime. #448

Merged
merged 1 commit into from
Nov 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions storagemarket/impl/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ type StoredAsk interface {
type Provider struct {
net network.StorageMarketNetwork

proofType abi.RegisteredSealProof

spn storagemarket.StorageProviderNode
fs filestore.FileStore
multiStore *multistore.MultiStore
Expand Down Expand Up @@ -107,7 +105,6 @@ func NewProvider(net network.StorageMarketNetwork,
dataTransfer datatransfer.Manager,
spn storagemarket.StorageProviderNode,
minerAddress address.Address,
rt abi.RegisteredSealProof,
storedAsk StoredAsk,
options ...StorageProviderOption,
) (storagemarket.StorageProvider, error) {
Expand All @@ -116,7 +113,6 @@ func NewProvider(net network.StorageMarketNetwork,

h := &Provider{
net: net,
proofType: rt,
spn: spn,
fs: fs,
multiStore: multiStore,
Expand Down Expand Up @@ -313,7 +309,13 @@ func (p *Provider) ImportDataForDeal(ctx context.Context, propCid cid.Cid, data
return xerrors.Errorf("failed to seek through temp imported file: %w", err)
}

pieceCid, _, err := pieceio.GeneratePieceCommitment(p.proofType, tempfi, pieceSize)
proofType, err := p.spn.GetProofType(ctx, p.actor, nil)
if err != nil {
cleanup()
return xerrors.Errorf("failed to determine proof type: %w", err)
}

pieceCid, _, err := pieceio.GeneratePieceCommitment(proofType, tempfi, pieceSize)
if err != nil {
cleanup()
return xerrors.Errorf("failed to generate commP")
Expand Down
8 changes: 6 additions & 2 deletions storagemarket/impl/provider_environments.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,14 @@ func (p *providerDealEnvironment) DeleteStore(storeID multistore.StoreID) error
}

func (p *providerDealEnvironment) GeneratePieceCommitmentToFile(storeID *multistore.StoreID, payloadCid cid.Cid, selector ipld.Node) (cid.Cid, filestore.Path, filestore.Path, error) {
proofType, err := p.p.spn.GetProofType(context.TODO(), p.p.actor, nil)
if err != nil {
return cid.Undef, "", "", err
}
if p.p.universalRetrievalEnabled {
return providerutils.GeneratePieceCommitmentWithMetadata(p.p.fs, p.p.pio.GeneratePieceCommitmentToFile, p.p.proofType, payloadCid, selector, storeID)
return providerutils.GeneratePieceCommitmentWithMetadata(p.p.fs, p.p.pio.GeneratePieceCommitmentToFile, proofType, payloadCid, selector, storeID)
}
pieceCid, piecePath, _, err := p.p.pio.GeneratePieceCommitmentToFile(p.p.proofType, payloadCid, selector, storeID)
pieceCid, piecePath, _, err := p.p.pio.GeneratePieceCommitmentToFile(proofType, payloadCid, selector, storeID)
return pieceCid, piecePath, filestore.Path(""), err
}

Expand Down
2 changes: 0 additions & 2 deletions storagemarket/impl/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ func TestProvider_Migrations(t *testing.T) {
deps.DTProvider,
deps.ProviderNode,
deps.ProviderAddr,
abi.RegisteredSealProof_StackedDrg2KiBV1,
deps.StoredAsk,
)
require.NoError(t, err)
Expand Down Expand Up @@ -228,7 +227,6 @@ func TestHandleDealStream(t *testing.T) {
deps.DTProvider,
deps.ProviderNode,
deps.ProviderAddr,
abi.RegisteredSealProof_StackedDrg2KiBV1,
deps.StoredAsk,
)
require.NoError(t, err)
Expand Down
3 changes: 3 additions & 0 deletions storagemarket/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ type StorageProviderNode interface {

// GetDataCap gets the current data cap for addr
GetDataCap(ctx context.Context, addr address.Address, tok shared.TipSetToken) (*verifreg.DataCap, error)

// GetProofType gets the current seal proof type for the given miner.
GetProofType(ctx context.Context, addr address.Address, tok shared.TipSetToken) (abi.RegisteredSealProof, error)
}

// StorageClientNode are node dependencies for a StorageClient
Expand Down
2 changes: 0 additions & 2 deletions storagemarket/testharness/testharness.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ func NewHarnessWithTestData(t *testing.T, ctx context.Context, td *shared_testut
deps.DTProvider,
deps.ProviderNode,
deps.ProviderAddr,
abi.RegisteredSealProof_StackedDrg2KiBV1,
deps.StoredAsk,
)
assert.NoError(t, err)
Expand Down Expand Up @@ -131,7 +130,6 @@ func (h *StorageHarness) CreateNewProvider(t *testing.T, ctx context.Context, td
dt2,
h.ProviderNode,
h.ProviderAddr,
abi.RegisteredSealProof_StackedDrg2KiBV1,
h.StoredAsk,
)
require.NoError(t, err)
Expand Down
5 changes: 5 additions & 0 deletions storagemarket/testnodes/testnodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,4 +361,9 @@ func (n *FakeProviderNode) GetDataCap(ctx context.Context, addr address.Address,
return n.DataCap, n.GetDataCapErr
}

// GetProofType returns the miner's proof type.
func (n *FakeProviderNode) GetProofType(ctx context.Context, addr address.Address, tok shared.TipSetToken) (abi.RegisteredSealProof, error) {
return abi.RegisteredSealProof_StackedDrg2KiBV1, nil
}

var _ storagemarket.StorageProviderNode = (*FakeProviderNode)(nil)