diff --git a/chain/deals/client.go b/chain/deals/client.go index fc7176715..70fe26252 100644 --- a/chain/deals/client.go +++ b/chain/deals/client.go @@ -40,7 +40,7 @@ var log = logging.Logger("deals") type ClientDeal struct { ProposalCid cid.Cid - Proposal UnsignedStorageDealProposal + Proposal StorageDealProposal State api.DealState Miner peer.ID @@ -189,7 +189,7 @@ func (c *Client) VerifyParams(ctx context.Context, data cid.Cid) (*actors.PieceI } func (c *Client) Start(ctx context.Context, p ClientDealProposal, vd *actors.PieceInclVoucherData) (cid.Cid, error) { - proposal := UnsignedStorageDealProposal{ + proposal := StorageDealProposal{ PieceRef: p.Data, SerializationMode: SerializationUnixFs, CommP: vd.CommP[:], @@ -197,8 +197,8 @@ func (c *Client) Start(ctx context.Context, p ClientDealProposal, vd *actors.Pie TotalPrice: p.TotalPrice, Duration: p.Duration, Payment: p.Payment, - Provider: p.MinerAddress, - Client: p.ClientAddress, + MinerAddress: p.MinerAddress, + ClientAddress: p.ClientAddress, } s, err := c.h.NewStream(ctx, p.MinerID, ProtocolID) @@ -229,7 +229,7 @@ func (c *Client) Start(ctx context.Context, p ClientDealProposal, vd *actors.Pie // TODO: start tracking after the deal is sealed return deal.ProposalCid, c.discovery.AddPeer(p.Data, discovery.RetrievalPeer{ - Address: proposal.Provider, + Address: proposal.MinerAddress, ID: deal.Miner, }) } diff --git a/chain/deals/client_utils.go b/chain/deals/client_utils.go index 935694fa1..159bf20e9 100644 --- a/chain/deals/client_utils.go +++ b/chain/deals/client_utils.go @@ -64,7 +64,7 @@ func (c *Client) commP(ctx context.Context, data cid.Cid) ([]byte, int64, error) return commP[:], size, err } -func (c *Client) sendProposal(s inet.Stream, proposal UnsignedStorageDealProposal, from address.Address) error { +func (c *Client) sendProposal(s inet.Stream, proposal StorageDealProposal, from address.Address) error { log.Info("Sending deal proposal") msg, err := cbor.DumpObject(proposal) @@ -76,7 +76,7 @@ func (c *Client) sendProposal(s inet.Stream, proposal UnsignedStorageDealProposa return err } - signedProposal := &StorageDealProposal{ + signedProposal := &SignedStorageDealProposal{ Proposal: proposal, Signature: sig, } diff --git a/chain/deals/handler.go b/chain/deals/handler.go index 1e796108d..112f827f5 100644 --- a/chain/deals/handler.go +++ b/chain/deals/handler.go @@ -27,7 +27,7 @@ func init() { type MinerDeal struct { Client peer.ID - Proposal UnsignedStorageDealProposal + Proposal StorageDealProposal ProposalCid cid.Cid State api.DealState @@ -194,7 +194,7 @@ func (h *Handler) onUpdated(ctx context.Context, update minerDealUpdate) { } } -func (h *Handler) newDeal(s inet.Stream, proposal UnsignedStorageDealProposal) (MinerDeal, error) { +func (h *Handler) newDeal(s inet.Stream, proposal StorageDealProposal) (MinerDeal, error) { // TODO: Review: Not signed? proposalNd, err := cbor.WrapObject(proposal, math.MaxUint64, -1) if err != nil { diff --git a/chain/deals/handler_states.go b/chain/deals/handler_states.go index 376bcced7..573b8d202 100644 --- a/chain/deals/handler_states.go +++ b/chain/deals/handler_states.go @@ -52,8 +52,8 @@ func (h *Handler) checkVoucher(ctx context.Context, deal MinerDeal, voucher *typ return xerrors.New("voucher.Extra not set") } - if voucher.Extra.Actor != deal.Proposal.Provider { - return xerrors.Errorf("extra params actor didn't match miner address in proposal: '%s' != '%s'", voucher.Extra.Actor, deal.Proposal.Provider) + if voucher.Extra.Actor != deal.Proposal.MinerAddress { + return xerrors.Errorf("extra params actor didn't match miner address in proposal: '%s' != '%s'", voucher.Extra.Actor, deal.Proposal.MinerAddress) } if voucher.Extra.Method != actors.MAMethods.PaymentVerifyInclusion { @@ -294,7 +294,7 @@ func (h *Handler) sealing(ctx context.Context, deal MinerDeal) (func(*MinerDeal) } func (h *Handler) complete(ctx context.Context, deal MinerDeal) (func(*MinerDeal), error) { - mcid, err := h.commt.WaitCommit(ctx, deal.Proposal.Provider, deal.SectorID) + mcid, err := h.commt.WaitCommit(ctx, deal.Proposal.MinerAddress, deal.SectorID) if err != nil { log.Warnf("Waiting for sector commitment message: %s", err) } diff --git a/chain/deals/handler_utils.go b/chain/deals/handler_utils.go index 4f20133cf..a3a4742e9 100644 --- a/chain/deals/handler_utils.go +++ b/chain/deals/handler_utils.go @@ -46,18 +46,18 @@ func (h *Handler) failDeal(id cid.Cid, cerr error) { } } -func (h *Handler) readProposal(s inet.Stream) (proposal StorageDealProposal, err error) { +func (h *Handler) readProposal(s inet.Stream) (proposal SignedStorageDealProposal, err error) { if err := cborrpc.ReadCborRPC(s, &proposal); err != nil { log.Errorw("failed to read proposal message", "error", err) - return StorageDealProposal{}, err + return SignedStorageDealProposal{}, err } // TODO: Validate proposal maybe // (and signature, obviously) - if proposal.Proposal.Provider != h.actor { - log.Errorf("proposal with wrong Provider: %s", proposal.Proposal.Provider) - return StorageDealProposal{}, err + if proposal.Proposal.MinerAddress != h.actor { + log.Errorf("proposal with wrong MinerAddress: %s", proposal.Proposal.MinerAddress) + return SignedStorageDealProposal{}, err } return diff --git a/chain/deals/types.go b/chain/deals/types.go index 19a0f6058..ddc754b7e 100644 --- a/chain/deals/types.go +++ b/chain/deals/types.go @@ -5,13 +5,14 @@ import ( "github.com/ipfs/go-cid" cbor "github.com/ipfs/go-ipld-cbor" + "github.com/filecoin-project/go-lotus/chain/actors" "github.com/filecoin-project/go-lotus/chain/address" "github.com/filecoin-project/go-lotus/chain/types" ) func init() { - cbor.RegisterCborType(UnsignedStorageDealProposal{}) cbor.RegisterCborType(StorageDealProposal{}) + cbor.RegisterCborType(SignedStorageDealProposal{}) cbor.RegisterCborType(PieceInclusionProof{}) @@ -33,26 +34,25 @@ const ( SerializationIPLD = "IPLD" ) -type UnsignedStorageDealProposal struct { - PieceRef cid.Cid // TODO: port to spec - PieceSize uint64 +type StorageDealProposal struct { + PieceRef cid.Cid // TODO: port to spec + SerializationMode SerializationMode + CommP []byte - Client address.Address - Provider address.Address + Size uint64 + TotalPrice types.BigInt + Duration uint64 - ProposalExpiryEpoch uint64 - DealExpiryEpoch uint64 + Payment actors.PaymentInfo - StoragePrice types.BigInt - StorageCollateral types.BigInt - - ProposerSignature *types.Signature + MinerAddress address.Address + ClientAddress address.Address } -type StorageDealProposal struct { - UnsignedStorageDealProposal // TODO: check bytes +type SignedStorageDealProposal struct { + Proposal StorageDealProposal - ProposerSignature *types.Signature + Signature *types.Signature } // response diff --git a/node/impl/client/client.go b/node/impl/client/client.go index 730141bfa..2bc8128ee 100644 --- a/node/impl/client/client.go +++ b/node/impl/client/client.go @@ -134,7 +134,7 @@ func (a *API) ClientListDeals(ctx context.Context) ([]api.DealInfo, error) { out[k] = api.DealInfo{ ProposalCid: v.ProposalCid, State: v.State, - Miner: v.Proposal.Provider, + Miner: v.Proposal.MinerAddress, PieceRef: v.Proposal.PieceRef, CommP: v.Proposal.CommP,