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

Update to go data transfer v1.6.0 #550

Merged
merged 2 commits into from
Jun 1, 2021
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/filecoin-project/go-address v0.0.3
github.com/filecoin-project/go-cbor-util v0.0.0-20191219014500-08c40a1e63a2
github.com/filecoin-project/go-commp-utils v0.0.0-20201119054358-b88f7a96a434
github.com/filecoin-project/go-data-transfer v1.5.0
github.com/filecoin-project/go-data-transfer v1.6.0
github.com/filecoin-project/go-ds-versioning v0.1.0
github.com/filecoin-project/go-multistore v0.0.3
github.com/filecoin-project/go-padreader v0.0.0-20200903213702-ed5fae088b20
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ github.com/filecoin-project/go-commp-utils v0.0.0-20201119054358-b88f7a96a434/go
github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03 h1:2pMXdBnCiXjfCYx/hLqFxccPoqsSveQFxVLvNxy9bus=
github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03/go.mod h1:+viYnvGtUTgJRdy6oaeF4MTFKAfatX071MPDPBL11EQ=
github.com/filecoin-project/go-data-transfer v1.0.1/go.mod h1:UxvfUAY9v3ub0a21BSK9u3pB2aq30Y0KMsG+w9/ysyo=
github.com/filecoin-project/go-data-transfer v1.5.0 h1:eXmcq7boRl/S3plV0/h4qdxkM6EgFIXF9y3UdOL0VXE=
github.com/filecoin-project/go-data-transfer v1.5.0/go.mod h1:E3WW4mCEYwU2y65swPEajSZoFWFmfXt7uwGduoACZQc=
github.com/filecoin-project/go-data-transfer v1.6.0 h1:DHIzEc23ydRCCBwtFet3MfgO8gMpZEnw60Y+s71oX6o=
github.com/filecoin-project/go-data-transfer v1.6.0/go.mod h1:E3WW4mCEYwU2y65swPEajSZoFWFmfXt7uwGduoACZQc=
github.com/filecoin-project/go-ds-versioning v0.1.0 h1:y/X6UksYTsK8TLCI7rttCKEvl8btmWxyFMEeeWGUxIQ=
github.com/filecoin-project/go-ds-versioning v0.1.0/go.mod h1:mp16rb4i2QPmxBnmanUx8i/XANp+PFCCJWiAb+VW4/s=
github.com/filecoin-project/go-fil-commcid v0.0.0-20200716160307-8f644712406f/go.mod h1:Eaox7Hvus1JgPrL5+M3+h7aSPHc0cVqpSxA+TxIEpZQ=
Expand Down
22 changes: 10 additions & 12 deletions retrievalmarket/impl/clientstates/client_states.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,16 @@ func ProcessPaymentRequested(ctx fsm.Context, environment ClientDealEnvironment,
func SendFunds(ctx fsm.Context, environment ClientDealEnvironment, deal rm.ClientDealState) error {
totalBytesToPayFor := deal.TotalReceived

// If unsealing has been paid for, and not all blocks have been received
if deal.UnsealFundsPaid.GreaterThanEqual(deal.UnsealPrice) && !deal.AllBlocksReceived {
// If the number of bytes received is less than the number required
// for the current payment interval, no need to send a payment
if totalBytesToPayFor < deal.CurrentInterval {
log.Debugf("client: ignoring payment request for %d: total bytes to pay for %d < interval %d",
deal.PaymentRequested, totalBytesToPayFor, deal.CurrentInterval)
return ctx.Trigger(rm.ClientEventPaymentNotSent)
}

// Otherwise round the number of bytes to pay for down to the current interval
totalBytesToPayFor = deal.CurrentInterval
// If unsealing has been paid for, and not all blocks have been received,
// and the number of bytes received is less than the number required
// for the current payment interval, no need to send a payment
if deal.UnsealFundsPaid.GreaterThanEqual(deal.UnsealPrice) &&
!deal.AllBlocksReceived &&
totalBytesToPayFor < deal.CurrentInterval {

log.Debugf("client: ignoring payment request for %d: total bytes to pay for %d < interval %d",
deal.PaymentRequested, totalBytesToPayFor, deal.CurrentInterval)
return ctx.Trigger(rm.ClientEventPaymentNotSent)
}

tok, _, err := environment.Node().GetChainHead(ctx.Context())
Expand Down
4 changes: 2 additions & 2 deletions retrievalmarket/impl/dtutils/dtutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,15 @@ func TransportConfigurer(thisPeer peer.ID, storeGetter StoreGetter) datatransfer
otherPeer := channelID.OtherParty(thisPeer)
store, err := storeGetter.Get(otherPeer, dealProposal.ID)
if err != nil {
log.Errorf("attempting to configure data store: %w", err)
log.Errorf("attempting to configure data store: %s", err)
return
}
if store == nil {
return
}
err = gsTransport.UseStore(channelID, store.Loader, store.Storer)
if err != nil {
log.Errorf("attempting to configure data store: %w", err)
log.Errorf("attempting to configure data store: %s", err)
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions retrievalmarket/impl/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func TestClientCanMakeDealWithProvider(t *testing.T) {
{name: "multi-block file retrieval succeeds",
filename: "lorem.txt",
filesize: 19000,
voucherAmts: []abi.TokenAmount{abi.NewTokenAmount(10000000), abi.NewTokenAmount(19920000)},
voucherAmts: []abi.TokenAmount{abi.NewTokenAmount(10136000), abi.NewTokenAmount(19920000)},
},
{name: "multi-block file retrieval with zero price per byte succeeds",
filename: "lorem.txt",
Expand All @@ -269,7 +269,7 @@ func TestClientCanMakeDealWithProvider(t *testing.T) {
{name: "multi-block file retrieval succeeds with V1 params and AllSelector",
filename: "lorem.txt",
filesize: 19000,
voucherAmts: []abi.TokenAmount{abi.NewTokenAmount(10000000), abi.NewTokenAmount(19920000)},
voucherAmts: []abi.TokenAmount{abi.NewTokenAmount(10136000), abi.NewTokenAmount(19920000)},
paramsV1: true,
selector: shared.AllSelector()},
{name: "partial file retrieval succeeds with V1 params and selector recursion depth 1",
Expand All @@ -290,7 +290,7 @@ func TestClientCanMakeDealWithProvider(t *testing.T) {
{name: "succeeds for regular blockstore",
filename: "lorem.txt",
filesize: 19000,
voucherAmts: []abi.TokenAmount{abi.NewTokenAmount(10000000), abi.NewTokenAmount(19920000)},
voucherAmts: []abi.TokenAmount{abi.NewTokenAmount(10136000), abi.NewTokenAmount(19920000)},
skipStores: true,
},
{
Expand All @@ -303,14 +303,14 @@ func TestClientCanMakeDealWithProvider(t *testing.T) {
{name: "multi-block file retrieval succeeds, final block exceeds payment interval",
filename: "lorem.txt",
filesize: 19000,
voucherAmts: []abi.TokenAmount{abi.NewTokenAmount(9000000), abi.NewTokenAmount(19250000), abi.NewTokenAmount(19920000)},
voucherAmts: []abi.TokenAmount{abi.NewTokenAmount(9112000), abi.NewTokenAmount(19352000), abi.NewTokenAmount(19920000)},
paymentInterval: 9000,
paymentIntervalIncrease: 1250,
},
{name: "multi-block file retrieval succeeds, final block lands on payment interval",
filename: "lorem.txt",
filesize: 19000,
voucherAmts: []abi.TokenAmount{abi.NewTokenAmount(9000000), abi.NewTokenAmount(19920000)},
voucherAmts: []abi.TokenAmount{abi.NewTokenAmount(9112000), abi.NewTokenAmount(19920000)},
// Total bytes: 19,920
// intervals: 9,000 | 9,000 + (9,000 + 1920)
paymentInterval: 9000,
Expand All @@ -320,7 +320,7 @@ func TestClientCanMakeDealWithProvider(t *testing.T) {
filename: "lorem.txt",
filesize: 19000,
disableNewDeals: true,
voucherAmts: []abi.TokenAmount{abi.NewTokenAmount(10000000), abi.NewTokenAmount(19920000)},
voucherAmts: []abi.TokenAmount{abi.NewTokenAmount(10136000), abi.NewTokenAmount(19920000)},
},
}

Expand Down
2 changes: 0 additions & 2 deletions retrievalmarket/retrieval_restart_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ func TestBounceConnectionDealTransferOngoing(t *testing.T) {
restartConf := dtimpl.ChannelRestartConfig(channelmonitor.Config{
AcceptTimeout: 100 * time.Millisecond,
RestartBackoff: 100 * time.Millisecond,
RestartAckTimeout: 2 * time.Second,
RestartDebounce: 100 * time.Millisecond,
MaxConsecutiveRestarts: 5,
CompleteTimeout: 100 * time.Millisecond,
Expand Down Expand Up @@ -212,7 +211,6 @@ func TestBounceConnectionDealTransferUnsealing(t *testing.T) {
restartConf := dtimpl.ChannelRestartConfig(channelmonitor.Config{
AcceptTimeout: 100 * time.Millisecond,
RestartBackoff: 100 * time.Millisecond,
RestartAckTimeout: 2 * time.Second,
RestartDebounce: 100 * time.Millisecond,
MaxConsecutiveRestarts: 5,
CompleteTimeout: 100 * time.Millisecond,
Expand Down
8 changes: 4 additions & 4 deletions retrievalmarket/storage_retrieval_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func TestStorageRetrieval(t *testing.T) {
pricePerByte: abi.NewTokenAmount(1000),
paymentInterval: uint64(10000),
paymentIntervalIncrease: uint64(1000),
voucherAmts: []abi.TokenAmount{abi.NewTokenAmount(10000000), abi.NewTokenAmount(19920000)},
voucherAmts: []abi.TokenAmount{abi.NewTokenAmount(10136000), abi.NewTokenAmount(19920000)},
},

"zero unseal, zero price per byte": {
Expand All @@ -77,7 +77,7 @@ func TestStorageRetrieval(t *testing.T) {
pricePerByte: abi.NewTokenAmount(1000),
paymentInterval: uint64(10000),
paymentIntervalIncrease: uint64(1000),
voucherAmts: []abi.TokenAmount{abi.NewTokenAmount(1000), abi.NewTokenAmount(10001000), abi.NewTokenAmount(19921000)},
voucherAmts: []abi.TokenAmount{abi.NewTokenAmount(1000), abi.NewTokenAmount(10137000), abi.NewTokenAmount(19921000)},
},
}

Expand Down Expand Up @@ -124,7 +124,7 @@ func TestOfflineStorageRetrieval(t *testing.T) {
pricePerByte: abi.NewTokenAmount(1000),
paymentInterval: uint64(10000),
paymentIntervalIncrease: uint64(1000),
voucherAmts: []abi.TokenAmount{abi.NewTokenAmount(10000000), abi.NewTokenAmount(19920000)},
voucherAmts: []abi.TokenAmount{abi.NewTokenAmount(10136000), abi.NewTokenAmount(19920000)},
},

"zero unseal, zero price per byte": {
Expand All @@ -140,7 +140,7 @@ func TestOfflineStorageRetrieval(t *testing.T) {
pricePerByte: abi.NewTokenAmount(1000),
paymentInterval: uint64(10000),
paymentIntervalIncrease: uint64(1000),
voucherAmts: []abi.TokenAmount{abi.NewTokenAmount(1000), abi.NewTokenAmount(10001000), abi.NewTokenAmount(19921000)},
voucherAmts: []abi.TokenAmount{abi.NewTokenAmount(1000), abi.NewTokenAmount(10137000), abi.NewTokenAmount(19921000)},
},
}

Expand Down
4 changes: 2 additions & 2 deletions storagemarket/impl/dtutils/dtutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ func TransportConfigurer(storeGetter StoreGetter) datatransfer.TransportConfigur
}
store, err := storeGetter.Get(storageVoucher.Proposal)
if err != nil {
log.Errorf("attempting to configure data store: %w", err)
log.Errorf("attempting to configure data store: %s", err)
return
}
if store == nil {
return
}
err = gsTransport.UseStore(channelID, store.Loader, store.Storer)
if err != nil {
log.Errorf("attempting to configure data store: %w", err)
log.Errorf("attempting to configure data store: %s", err)
}
}
}
3 changes: 1 addition & 2 deletions storagemarket/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ func TestMakeDealOffline(t *testing.T) {
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
h := testharness.NewHarness(t, ctx, true, noOpDelay, noOpDelay, false)

shared_testutil.StartAndWaitForReady(ctx, t, h.Provider)
shared_testutil.StartAndWaitForReady(ctx, t, h.Client)

Expand Down Expand Up @@ -301,7 +302,6 @@ func TestRestartOnlyProviderDataTransfer(t *testing.T) {
restartConf := dtimpl.ChannelRestartConfig(channelmonitor.Config{
AcceptTimeout: 100 * time.Millisecond,
RestartBackoff: 100 * time.Millisecond,
RestartAckTimeout: 2 * time.Second,
RestartDebounce: 100 * time.Millisecond,
MaxConsecutiveRestarts: 5,
CompleteTimeout: 100 * time.Millisecond,
Expand Down Expand Up @@ -637,7 +637,6 @@ func TestBounceConnectionDataTransfer(t *testing.T) {
restartConf := dtimpl.ChannelRestartConfig(channelmonitor.Config{
AcceptTimeout: 100 * time.Millisecond,
RestartBackoff: 100 * time.Millisecond,
RestartAckTimeout: 2 * time.Second,
RestartDebounce: 100 * time.Millisecond,
MaxConsecutiveRestarts: 5,
CompleteTimeout: 100 * time.Millisecond,
Expand Down