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

Move to an explicit piecestore and explicit unsealing. #54

Merged
merged 5 commits into from
Jan 23, 2020

Conversation

hannahhoward
Copy link
Collaborator

Goals

Reduce the node adapter interfaces so they can be satisfied by both go-filecoin and lotus, while also fully supporting CAR files and seperating interface boundaries

Implementation

  • Use a piece info state data base to track connections between CommP & deals
  • Wait for deal sealing in provider side then store sector info about piece
  • The CID Info would eventually be generated when writing the CAR
  • Add unsealing explicitly to the retrieval side and add tests

hannahhoward and others added 4 commits January 22, 2020 13:17
Outlines node interface changes and relevant code to remove the need for the node to track
information about pieces
When retrieving, manually unseal as neccesary based on piece CID, removing need for node
implementors to maintain transparently sealed blockstore
Initial implementation of the piecestore - based on statestore
@codecov-io
Copy link

codecov-io commented Jan 22, 2020

Codecov Report

Merging #54 into master will increase coverage by 1.4%.
The diff coverage is 47.06%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master      #54     +/-   ##
=========================================
+ Coverage   32.43%   33.82%   +1.4%     
=========================================
  Files          33       36      +3     
  Lines        2350     2608    +258     
=========================================
+ Hits          762      882    +120     
- Misses       1514     1590     +76     
- Partials       74      136     +62
Impacted Files Coverage Δ
retrievalmarket/impl/client.go 69.86% <ø> (ø) ⬆️
retrievalmarket/network/libp2p_impl.go 61.77% <ø> (ø) ⬆️
retrievalmarket/network/query_stream.go 66.67% <ø> (ø) ⬆️
retrievalmarket/impl/blockio/reader.go 71.43% <ø> (ø) ⬆️
storagemarket/impl/provider_states.go 0% <0%> (ø) ⬆️
storagemarket/impl/provider.go 0% <0%> (ø) ⬆️
...ievalmarket/impl/providerstates/provider_states.go 94.32% <100%> (ø) ⬆️
piecestore/types_cbor_gen.go 29.45% <29.45%> (ø)
retrievalmarket/impl/provider.go 72.36% <76.48%> (+0.81%) ⬆️
piecestore/piecestore.go 86.37% <86.37%> (ø)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c44b6fe...5d352f3. Read the comment docs.

Copy link
Contributor

@ingar ingar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some non-blocking comments... 👍

}

func (ps *pieceStore) AddDealForPiece(pieceCID []byte, dealInfo DealInfo) error {
// Do we need to de-dupe or anything here?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is wondering about whether adding duplicate DealInfo (or BlockInfo below) is necessarily bad or not. Since it's a local store maybe it's not a big deal.

Comment on lines +38 to +39
HasBlockInfo(pieceCID []byte) (bool, error)
HasDealInfo(pieceCID []byte) (bool, error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these going to be used in another context? They are unused here -- or would they be more useful if they didn't return an error?

@hannahhoward
Copy link
Collaborator Author

@ingar I'm gonna mess with this interface some more in my next PR, cause I realize we actually are gonna have to change some more things... :( so let's not block on it for now.

Copy link
Contributor

@shannonwells shannonwells left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the suggestions I have are super minor. Your call

assert.NoError(t, err)
blockInfos := []piecestore.BlockInfo{{testCid, 42, 43}}

err = ps.AddBlockInfosToPiece(pieceCid, blockInfos)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should really be broken up into test cases for test hygiene and easier auditing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this is gonna get changed a bunch shortly so I will hold off for now

@@ -10,6 +10,8 @@ import (
"github.com/filecoin-project/go-fil-markets/shared/types"
)

// TestRetrievalClientNode is a node adapter for a retrieval client whose responses
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙇‍♀ for clarifying comments

retrievalmarket/impl/blockunsealing/blockunsealing.go Outdated Show resolved Hide resolved
)

func TestNewLoaderWithUnsealing(t *testing.T) {
ctx := context.Background()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand at this time how IPLD trees work so I can't review this adequately.


// attemp to load again, will not unseal, will fail
_, err = loaderWithUnsealing.Load(testdata.MiddleMapNodeLnk, ipld.LinkContext{})
require.Error(t, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd feel better with require/assert.EqualError to check that the error is what you expected.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea so, this isn't the best test, but the error is actually the same as if it weren't in the blockstore --

if it unsealed a second time, it would work, cause it would put the deleted block back in the block store.

so it's not a specific error -- it just doesn't attempt another unseal -- and then fails reading from the blockstore as a result

retrievalmarket/impl/clientstates/client_states.go Outdated Show resolved Hide resolved

if err == nil {
if err == nil && len(pieceInfo.Deals) > 0 {
answer.Status = retrievalmarket.QueryResponseAvailable
// TODO: get price, look for already unsealed ref to reduce work
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these TODOs need to be captured in issues?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nah that's copied code that should get deleted :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually i'm not sure will take another look

providerNode.ExpectPiece(piece, expectedQR.Size*uint64(i+1))
pieceStore.ExpectPiece(piece, piecestore.PieceInfo{
Deals: []piecestore.DealInfo{
piecestore.DealInfo{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the inner piecestore.DealInfo is redundant. only worth changing if you're touching the file IMO

Fix todos, import orders, extraneous typing
@hannahhoward hannahhoward merged commit 77e66fe into master Jan 23, 2020
@hannahhoward hannahhoward deleted the feat/maintain-piece-references branch April 30, 2020 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants