-
Notifications
You must be signed in to change notification settings - Fork 59
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
Conversation
33d4b5b
to
c327a27
Compare
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
0e52ddf
to
7c7c4f8
Compare
There was a problem hiding this 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 |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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
There was a problem hiding this 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), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
linters, amirite?
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
7c7c4f8
to
bf39448
Compare
bf39448
to
ddf6b73
Compare
Goals
Use spec actor types, unifying various go actor types
Implementation
tokenamount.Tokenamount
with TokenAmount fromspecs-actors
abi
package. Usespecs-actors
big
type for operationstypes.Signature
, replace with Signature fromspecs-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 featuretypes.SignedVoucher
, replace with SignedVoucher fromspecs-actors
paych
packagetypes.SignedStorageAsk
tostoragemarket
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 chainstoragemarket.StorageDealProposal
withspec-actors
ClientDealProposal + Deal Proposal. This also necessitates switching to real PieceCIDs, which we handle with thego-fil-commcid
package