diff --git a/chain/deals/provider_states.go b/chain/deals/provider_states.go index ea5c6c772..5e5dbc273 100644 --- a/chain/deals/provider_states.go +++ b/chain/deals/provider_states.go @@ -12,6 +12,7 @@ import ( "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/address" "github.com/filecoin-project/lotus/chain/types" + "github.com/filecoin-project/lotus/lib/padreader" "github.com/filecoin-project/lotus/storage/sectorblocks" ) @@ -218,8 +219,8 @@ func (p *Provider) staged(ctx context.Context, deal MinerDeal) (func(*MinerDeal) if err != nil { return nil, xerrors.Errorf("getting unixfs file size: %w", err) } - if uint64(size) != deal.Proposal.PieceSize { - return nil, xerrors.Errorf("deal.Proposal.PieceSize didn't match unixfs file size") + if padreader.PaddedSize(uint64(size)) != deal.Proposal.PieceSize { + return nil, xerrors.Errorf("deal.Proposal.PieceSize didn't match padded unixfs file size") } sectorID, err := p.secb.AddUnixfsPiece(deal.Ref, uf, deal.DealID) diff --git a/lotuspond/front/src/Client.js b/lotuspond/front/src/Client.js index 37606223b..70aabfd6f 100644 --- a/lotuspond/front/src/Client.js +++ b/lotuspond/front/src/Client.js @@ -21,7 +21,7 @@ class Client extends React.Component { this.state = { miners: ["t0101"], - ask: {Price: "500000000"}, + ask: {Price: "1000000000"}, // 2x min default ask to account for bin packing (could also do the math correctly below, but..) kbs: 1, blocks: 12, @@ -52,7 +52,7 @@ class Client extends React.Component { update = (name) => (e) => this.setState({ [name]: e.target.value }); makeDeal = async () => { - let perBlk = this.state.ask.Price * this.state.kbs * 1000 / (1 << 30) + let perBlk = this.state.ask.Price * this.state.kbs * 1000 / (1 << 30) * 2 let file = await this.props.pondClient.call('Pond.CreateRandomFile', [this.state.kbs * 1000]) // 1024 won't fit in 1k blocks :( let cid = await this.props.client.call('Filecoin.ClientImport', [file]) diff --git a/storage/sectorblocks/blocks.go b/storage/sectorblocks/blocks.go index d46ef9f1b..1d1289def 100644 --- a/storage/sectorblocks/blocks.go +++ b/storage/sectorblocks/blocks.go @@ -20,6 +20,7 @@ import ( "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/lib/cborrpc" + "github.com/filecoin-project/lotus/lib/padreader" "github.com/filecoin-project/lotus/lib/sectorbuilder" "github.com/filecoin-project/lotus/node/modules/dtypes" "github.com/filecoin-project/lotus/storage/sector" @@ -172,7 +173,9 @@ func (st *SectorBlocks) AddUnixfsPiece(ref cid.Cid, r UnixfsReader, dealID uint6 intermediate: st.intermediate, } - return st.Store.AddPiece(refst.pieceRef, uint64(size), refst, dealID) + pr, psize := padreader.New(r, uint64(size)) + + return st.Store.AddPiece(refst.pieceRef, psize, pr, dealID) } func (st *SectorBlocks) List() (map[cid.Cid][]api.SealedRef, error) {