From 738e8c5a3c1eb9cc1a186487907c83ffbecf5648 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 29 Oct 2019 11:19:39 +0100 Subject: [PATCH] deals: Ask prices per GiB --- chain/deals/provider.go | 2 +- chain/deals/provider_states.go | 2 +- chain/types/ask.go | 2 ++ cli/client.go | 5 +++-- lotuspond/front/src/Client.js | 4 ++-- lotuspond/front/src/State.js | 4 ++-- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/chain/deals/provider.go b/chain/deals/provider.go index 5a3c0ab65..86383c61b 100644 --- a/chain/deals/provider.go +++ b/chain/deals/provider.go @@ -109,7 +109,7 @@ func NewProvider(ds dtypes.MetadataDS, secst *sectorblocks.SectorBlocks, commt * if h.ask == nil { // TODO: we should be fine with this state, and just say it means 'not actively accepting deals' // for now... lets just set a price - if err := h.SetPrice(types.NewInt(3), 1000000); err != nil { + if err := h.SetPrice(types.NewInt(500_000_000), 1000000); err != nil { return nil, xerrors.Errorf("failed setting a default price: %w", err) } } diff --git a/chain/deals/provider_states.go b/chain/deals/provider_states.go index 72e7d17bf..7df6c29c6 100644 --- a/chain/deals/provider_states.go +++ b/chain/deals/provider_states.go @@ -88,7 +88,7 @@ func (p *Provider) accept(ctx context.Context, deal MinerDeal) (func(*MinerDeal) // TODO: check StorageCollateral // TODO: - minPrice := types.BigMul(p.ask.Ask.Price, types.NewInt(deal.Proposal.PieceSize)) + minPrice := types.BigDiv(types.BigMul(p.ask.Ask.Price, types.NewInt(deal.Proposal.PieceSize)), types.NewInt(1 << 30)) if deal.Proposal.StoragePricePerEpoch.LessThan(minPrice) { return nil, xerrors.Errorf("storage price per epoch less than asking price: %s < %s", deal.Proposal.StoragePricePerEpoch, minPrice) } diff --git a/chain/types/ask.go b/chain/types/ask.go index 1e74c9cb6..3e1767b06 100644 --- a/chain/types/ask.go +++ b/chain/types/ask.go @@ -16,7 +16,9 @@ type SignedStorageAsk struct { } type StorageAsk struct { + // Price per GiB / Epoch Price BigInt + MinPieceSize uint64 Miner address.Address Timestamp uint64 diff --git a/cli/client.go b/cli/client.go index e9e5814c7..2a6b855bf 100644 --- a/cli/client.go +++ b/cli/client.go @@ -314,13 +314,14 @@ var clientQueryAskCmd = &cli.Command{ if size == 0 { return nil } - fmt.Printf("Price per Block: %s\n", types.BigMul(ask.Ask.Price, types.NewInt(uint64(size)))) + perEpoch := types.BigDiv(types.BigMul(ask.Ask.Price, types.NewInt(uint64(size))), types.NewInt(1<<30)) + fmt.Printf("Price per Block: %s\n", perEpoch) duration := cctx.Int64("duration") if duration == 0 { return nil } - fmt.Printf("Total Price: %s\n", types.BigMul(types.BigMul(ask.Ask.Price, types.NewInt(uint64(size))), types.NewInt(uint64(duration)))) + fmt.Printf("Total Price: %s\n", types.BigMul(perEpoch, types.NewInt(uint64(duration)))) return nil }, diff --git a/lotuspond/front/src/Client.js b/lotuspond/front/src/Client.js index 35aaab148..37606223b 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: "3"}, + ask: {Price: "500000000"}, 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 + let perBlk = this.state.ask.Price * this.state.kbs * 1000 / (1 << 30) 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/lotuspond/front/src/State.js b/lotuspond/front/src/State.js index 6fb1a70aa..93252505d 100644 --- a/lotuspond/front/src/State.js +++ b/lotuspond/front/src/State.js @@ -123,10 +123,10 @@ class MarketState extends React.Component { {Object.keys(this.state.deals).map(d => {d} {this.state.deals[d].ActivationEpoch || "No"} -
+
{this.state.deals[d].Deal.Proposal.PieceSize}B - {this.state.deals[d].Deal.Proposal.StoragePrice} + {this.state.deals[d].Deal.Proposal.StoragePricePerEpoch*this.state.deals[d].Deal.Proposal.Duration} {this.state.deals[d].Deal.Proposal.Duration} )}