Fix deal publishing

This commit is contained in:
Łukasz Magiera 2020-04-16 23:43:39 +02:00
parent 918b759d03
commit 15a4565714
7 changed files with 26 additions and 21 deletions

View File

@ -324,7 +324,7 @@ type StartDealParams struct {
Wallet address.Address
Miner address.Address
EpochPrice types.BigInt
BlocksDuration uint64
MinBlocksDuration uint64
}
type IpldObject struct {

View File

@ -87,7 +87,7 @@ func TestDealFlow(t *testing.T, b APIBuilder, blocktime time.Duration, carExport
Wallet: addr,
Miner: maddr,
EpochPrice: types.NewInt(1000000),
BlocksDuration: 100,
MinBlocksDuration: 100,
})
if err != nil {
t.Fatalf("%+v", err)

View File

@ -191,7 +191,7 @@ var clientDealCmd = &cli.Command{
Wallet: a,
Miner: miner,
EpochPrice: types.BigInt(price),
BlocksDuration: uint64(dur),
MinBlocksDuration: uint64(dur),
})
if err != nil {
return err

2
go.mod
View File

@ -25,7 +25,7 @@ require (
github.com/filecoin-project/go-paramfetch v0.0.2-0.20200218225740-47c639bab663
github.com/filecoin-project/go-statestore v0.1.0
github.com/filecoin-project/sector-storage v0.0.0-20200411000242-61616264b16d
github.com/filecoin-project/specs-actors v0.0.0-20200416120818-2fbe2e4dee24
github.com/filecoin-project/specs-actors v0.0.0-20200416213853-1bd9b52a4621
github.com/filecoin-project/specs-storage v0.0.0-20200410185809-9fbaaa08f275
github.com/filecoin-project/storage-fsm v0.0.0-20200415180041-afc45d4b6e8b
github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1

2
go.sum
View File

@ -190,6 +190,8 @@ github.com/filecoin-project/specs-actors v0.0.0-20200415170224-54c7b2a42e71 h1:k
github.com/filecoin-project/specs-actors v0.0.0-20200415170224-54c7b2a42e71/go.mod h1:M2HNOBpYbgXl/V4GmJFOsY7lQNuAmOtrCQMa6Yfpfrc=
github.com/filecoin-project/specs-actors v0.0.0-20200416120818-2fbe2e4dee24 h1:r/a/rs912gOE5Z5AzKJXa7jHu3asRt/cHO30odPTMoE=
github.com/filecoin-project/specs-actors v0.0.0-20200416120818-2fbe2e4dee24/go.mod h1:qNIpwxs7WCtxbcbG4ZiS+Wf3qn36eyfqktlXJhi46X4=
github.com/filecoin-project/specs-actors v0.0.0-20200416213853-1bd9b52a4621 h1:czpP1yymltKqEjCfQptXkn01rkkAqgf1nEmIPcRbO/I=
github.com/filecoin-project/specs-actors v0.0.0-20200416213853-1bd9b52a4621/go.mod h1:qNIpwxs7WCtxbcbG4ZiS+Wf3qn36eyfqktlXJhi46X4=
github.com/filecoin-project/specs-storage v0.0.0-20200410185809-9fbaaa08f275 h1:6OTcpsTQBQM0f/A67oEi4E4YtYd6fzkMqbU8cPIWMMs=
github.com/filecoin-project/specs-storage v0.0.0-20200410185809-9fbaaa08f275/go.mod h1:xJ1/xl9+8zZeSSSFmDC3Wr6uusCTxyYPI0VeNVSFmPE=
github.com/filecoin-project/storage-fsm v0.0.0-20200413200947-069c3b2468ca h1:TejufIAWDpEVqFUCszDpgOEzXBWuTVltsDQL/3F8Jxo=

View File

@ -172,7 +172,7 @@ func (c *ClientNodeAdapter) ValidatePublishedDeal(ctx context.Context, deal stor
return 0, xerrors.Errorf("getting deal pubsish message: %w", err)
}
mi, err := stmgr.StateMinerInfo(ctx, c.sm, nil, deal.Proposal.Provider)
mi, err := stmgr.StateMinerInfo(ctx, c.sm, c.cs.GetHeaviestTipSet(), deal.Proposal.Provider)
if err != nil {
return 0, xerrors.Errorf("getting miner worker failed: %w", err)
}

View File

@ -6,9 +6,6 @@ import (
"io"
"os"
"github.com/filecoin-project/sector-storage/ffiwrapper"
"github.com/filecoin-project/specs-actors/actors/abi/big"
"golang.org/x/xerrors"
"github.com/ipfs/go-blockservice"
@ -29,7 +26,10 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
"github.com/filecoin-project/go-fil-markets/storagemarket"
"github.com/filecoin-project/sector-storage/ffiwrapper"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/abi/big"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
@ -86,13 +86,16 @@ func (a *API) ClientStartDeal(ctx context.Context, params *api.StartDealParams)
return nil, xerrors.Errorf("failed getting chain height: %w", err)
}
exp := ts.Height()+dealStartBuffer+abi.ChainEpoch(params.MinBlocksDuration)
exp += miner.WPoStProvingPeriod - (exp % miner.WPoStProvingPeriod) + mi.ProvingPeriodBoundary - 1
result, err := a.SMDealClient.ProposeStorageDeal(
ctx,
params.Wallet,
&providerInfo,
params.Data,
ts.Height()+dealStartBuffer,
ts.Height()+dealStartBuffer+abi.ChainEpoch(params.BlocksDuration),
exp,
params.EpochPrice,
big.Zero(),
rt,