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

Import spec actor types #118

Merged
merged 7 commits into from
Feb 12, 2020
Merged

Import spec actor types #118

merged 7 commits into from
Feb 12, 2020

Conversation

hannahhoward
Copy link
Collaborator

@hannahhoward hannahhoward commented Feb 7, 2020

Goals

Use spec actor types, unifying various go actor types

Implementation

  • Replace tokenamount.Tokenamount with TokenAmount from specs-actors abi package. Use specs-actors big type for operations
  • Remove types.Signature, replace with Signature from specs-actors crypto package. Since this signature intentionally lacks a Verify function, add it as a function provided by the node implementation interface, which makes sense anyway since the node should have its own implementation of signature as it's a security critical feature
  • Remove types.SignedVoucher, replace with SignedVoucher from specs-actors paych package
  • Move types.SignedStorageAsk to storagemarket package, since this is the only place it's used and moreover, it's something that's unique to the shared markets as asks are not on chain
  • Remove shared folder entirely
  • Replace storagemarket.StorageDealProposal with spec-actors ClientDealProposal + Deal Proposal. This also necessitates switching to real PieceCIDs, which we handle with the go-fil-commcid package

@hannahhoward hannahhoward changed the title WIP: Import spec actor types Import spec actor types Feb 10, 2020
@codecov-io
Copy link

Codecov Report

Merging #118 into master will increase coverage by 1.91%.
The diff coverage is 14.81%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #118      +/-   ##
==========================================
+ Coverage   35.86%   37.77%   +1.91%     
==========================================
  Files          43       35       -8     
  Lines        3188     2619     -569     
==========================================
- Hits         1143      989     -154     
+ Misses       1730     1367     -363     
+ Partials      315      263      -52
Impacted Files Coverage Δ
storagemarket/impl/provider.go 0% <0%> (ø) ⬆️
storagemarket/impl/provider_states.go 0% <0%> (ø) ⬆️
storagemarket/impl/client_cbor_gen.go 5.18% <0%> (-1.8%) ⬇️
storagemarket/impl/client_storagemarket.go 0% <0%> (ø) ⬆️
storagemarket/impl/client_states.go 0% <0%> (ø) ⬆️
storagemarket/impl/provider_storagemarket.go 0% <0%> (ø) ⬆️
storagemarket/impl/client.go 0% <0%> (ø) ⬆️
storagemarket/impl/provider_asks.go 0% <0%> (ø) ⬆️
...ievalmarket/impl/providerstates/provider_states.go 94.32% <100%> (ø) ⬆️
retrievalmarket/impl/clientstates/client_states.go 99.02% <100%> (ø) ⬆️
... and 10 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 e814d5d...0e52ddf. 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.

Awesome. I mainly looked at storagemarket stuff, just a few comments.

Another general comment: seems like we are inconsistent with our usage of Miner and Provider. We should probably choose one and stick with it.

@@ -217,11 +166,14 @@ type StorageProvider interface {
type StorageProviderNode interface {
MostRecentStateId(ctx context.Context) (StateKey, error)

// Verify a signature against an address + data
VerifySignature(signature crypto.Signature, signer address.Address, plaintext []byte) bool
Copy link
Contributor

Choose a reason for hiding this comment

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

💯

@@ -128,6 +132,121 @@ func TestMakeDeal(t *testing.T) {
assert.Equal(t, pd.State, storagemarket.StorageDealActive)
}

func TestMakeDealOffline(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

PieceRef: commP,
PieceSize: uint64(pieceSize),
dealProposal := market.DealProposal{
PieceCID: commcid.PieceCommitmentV1ToCID(commP),
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to have PieceIO.GeneratePieceCommitment return a cid.CID? Would remove a little boilerplate from client and provider.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hmmm... good question. Let's leave it for a future discussion

@@ -45,13 +46,13 @@ func (p *Provider) validating(ctx context.Context, deal MinerDeal) (func(*MinerD
if err != nil {
return nil, err
}
if head.Height() >= deal.Proposal.ProposalExpiration {
if head.Height() >= deal.Proposal.StartEpoch {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not really related to this PR, but this check doesn't give us any slack time to seal/commit a sector before the StartEpoch.

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 we should make decision about that in the future

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.

Just a couple of questions, no blockers


func makeDealState(status retrievalmarket.DealStatus) *retrievalmarket.ClientDealState {
return &retrievalmarket.ClientDealState{
TotalFunds: defaultTotalFunds,
MinerWallet: address.TestAddress,
ClientWallet: address.TestAddress2,
PayCh: address.TestAddress2,
Lane: uint64(10),
Lane: int64(10),
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that now we need to make sure that Lanes are checked for <0 as well as any other place where a negative value would be bad.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd expect this to be changed back to uint64 in the spec

Copy link
Collaborator

Choose a reason for hiding this comment

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

This being int64 is a spec bug

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 I dunno what to do about this. I wish we weren't using signed ints in spec in so many places.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ListDeals() map[ProviderDealID]ProviderDealState
}

// RetrievalProviderNode are the node depedencies for a RetrevalProvider
type RetrievalProviderNode interface {
UnsealSector(ctx context.Context, sectorId uint64, offset uint64, length uint64) (io.ReadCloser, error)
SavePaymentVoucher(ctx context.Context, paymentChannel address.Address, voucher *types.SignedVoucher, proof []byte, expectedAmount tokenamount.TokenAmount) (tokenamount.TokenAmount, error)
UnsealSector(ctx context.Context, sectorID uint64, offset uint64, length uint64) (io.ReadCloser, error)
Copy link
Contributor

Choose a reason for hiding this comment

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

linters, amirite?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

seriously.

MinerID: info.PeerID,
Data: data,
PricePerEpoch: price,
StartEpoch: startEpoch,
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll need to make sure we guard against negative epochs now too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I feel like the check to see if StartEpoch > current chain height protects against that, but I wish we were using unsigned ints in spec

_, err = tempfi.Seek(0, io.SeekStart)
if err != nil {
return xerrors.Errorf("failed to seek through temp imported file: %w", err)
}

commP, err := p.pio.ReadPiece(tempfi)
Copy link
Contributor

Choose a reason for hiding this comment

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

is p.pio used anymore?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it is. elsewhere

Switch to the tokenamount in the spec-actor repo and remove tokenamount.TokenAmount
move ask to storage market, import voucher & signature from specs-actors
Just remove 2 references to a single constant that does not have the same meaning any more
use chains deal proposal and storage deal proposal, switch to using PieceCIDs, switch storageAsk to
chain epoch based, and have the piece store be keyed by CIDs as well.
use embedded struct to simplify property access
add an integration test to verify the offline deal flow is working
@hannahhoward hannahhoward merged commit a7bad90 into master Feb 12, 2020
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.

5 participants