diff --git a/go.sum b/go.sum index 0e14ed7b1..b6e36c0bd 100644 --- a/go.sum +++ b/go.sum @@ -113,6 +113,7 @@ github.com/filecoin-project/go-data-transfer v0.0.0-20191219005021-4accf56bd2ce github.com/filecoin-project/go-data-transfer v0.0.0-20191219005021-4accf56bd2ce/go.mod h1:b14UWxhxVCAjrQUYvVGrQRRsjAh79wXYejw9RbUcAww= github.com/filecoin-project/go-fil-markets v0.0.0-20200110170857-c200f161be42 h1:7OW2AiWtwxwtYnC16CiXZ/idQ7w3W7W1hhX+N4YSAyQ= github.com/filecoin-project/go-fil-markets v0.0.0-20200110170857-c200f161be42/go.mod h1:Q5fvJGMISyUIna19DpoqiqTas4L9RVD7w3Udv7uCrTo= +github.com/filecoin-project/go-fil-markets v0.0.0-20200110172620-7ac5a8af146a h1:mLz0GBjx8nlztlo2sZ6w1JbuyN7EX7zoCYQBblrgoBM= github.com/filecoin-project/go-paramfetch v0.0.0-20200102181131-b20d579f2878 h1:YicJT9xhPzZ1SBGiJFNUCkfwqK/G9vFyY1ytKBSjNJA= github.com/filecoin-project/go-paramfetch v0.0.0-20200102181131-b20d579f2878 h1:YicJT9xhPzZ1SBGiJFNUCkfwqK/G9vFyY1ytKBSjNJA= github.com/filecoin-project/go-paramfetch v0.0.0-20200102181131-b20d579f2878/go.mod h1:40kI2Gv16mwcRsHptI3OAV4nlOEU7wVDc4RgMylNFjU= diff --git a/node/impl/client/client.go b/node/impl/client/client.go index 70aff2b0c..12eaf117c 100644 --- a/node/impl/client/client.go +++ b/node/impl/client/client.go @@ -36,7 +36,6 @@ import ( "github.com/filecoin-project/lotus/node/impl/full" "github.com/filecoin-project/lotus/node/impl/paych" "github.com/filecoin-project/lotus/node/modules/dtypes" - "github.com/filecoin-project/lotus/retrievaladapter" "github.com/filecoin-project/lotus/storagemarketadapter" ) @@ -79,7 +78,7 @@ func (a *API) ClientStartDeal(ctx context.Context, data cid.Cid, addr address.Ad providerInfo := storagemarketadapter.NewStorageProviderInfo(miner, mw, 0, pid) result, err := a.SMDealClient.ProposeStorageDeal( ctx, - sharedutils.ToSharedAddress(addr), + addr, &providerInfo, data, storagemarket.Epoch(math.MaxUint64), @@ -105,7 +104,7 @@ func (a *API) ClientListDeals(ctx context.Context) ([]api.DealInfo, error) { out[k] = api.DealInfo{ ProposalCid: v.ProposalCid, State: v.State, - Provider: sharedutils.FromSharedAddress(v.Proposal.Provider), + Provider: v.Proposal.Provider, PieceRef: v.Proposal.PieceRef, Size: v.Proposal.PieceSize, @@ -127,7 +126,7 @@ func (a *API) ClientGetDealInfo(ctx context.Context, d cid.Cid) (*api.DealInfo, return &api.DealInfo{ ProposalCid: v.ProposalCid, State: v.State, - Provider: sharedutils.FromSharedAddress(v.Proposal.Provider), + Provider: v.Proposal.Provider, PieceRef: v.Proposal.PieceRef, Size: v.Proposal.PieceSize, PricePerEpoch: sharedutils.FromSharedTokenAmount(v.Proposal.StoragePricePerEpoch), @@ -159,13 +158,13 @@ func (a *API) ClientFindData(ctx context.Context, root cid.Cid) ([]api.QueryOffe for k, p := range peers { queryResponse, err := a.Retrieval.Query(ctx, p, root.Bytes(), retrievalmarket.QueryParams{}) if err != nil { - out[k] = api.QueryOffer{Err: err.Error(), Miner: retrievaladapter.FromSharedAddress(p.Address), MinerPeerID: p.ID} + out[k] = api.QueryOffer{Err: err.Error(), Miner: p.Address, MinerPeerID: p.ID} } else { out[k] = api.QueryOffer{ Root: root, Size: queryResponse.Size, - MinPrice: retrievaladapter.FromSharedTokenAmount(queryResponse.PieceRetrievalPrice()), - Miner: retrievaladapter.FromSharedAddress(p.Address), // TODO: check + MinPrice: sharedutils.FromSharedTokenAmount(queryResponse.PieceRetrievalPrice()), + Miner: p.Address, // TODO: check MinerPeerID: p.ID, } } @@ -297,8 +296,8 @@ func (a *API) ClientRetrieve(ctx context.Context, order api.RetrievalOrder, path retrievalmarket.NewParamsV0(types.BigDiv(order.Total, types.NewInt(order.Size)).Int, 0, 0), sharedutils.ToSharedTokenAmount(order.Total), order.MinerPeerID, - retrievaladapter.ToSharedAddress(order.Client), - retrievaladapter.ToSharedAddress(order.Miner)) + order.Client, + order.Miner) select { case <-ctx.Done(): return xerrors.New("Retrieval Timed Out") diff --git a/node/modules/services.go b/node/modules/services.go index e12b9a310..33f2733b5 100644 --- a/node/modules/services.go +++ b/node/modules/services.go @@ -10,6 +10,7 @@ import ( "github.com/filecoin-project/go-fil-markets/retrievalmarket" "github.com/filecoin-project/go-fil-markets/retrievalmarket/discovery" + "github.com/filecoin-project/go-fil-markets/storagemarket" "github.com/filecoin-project/lotus/chain" "github.com/filecoin-project/lotus/chain/blocksync" "github.com/filecoin-project/lotus/chain/messagepool" @@ -18,7 +19,6 @@ import ( "github.com/filecoin-project/lotus/node/modules/dtypes" "github.com/filecoin-project/lotus/node/modules/helpers" "github.com/filecoin-project/lotus/peermgr" - "github.com/filecoin-project/go-fil-components/storagemarket" ) func RunHello(mctx helpers.MetricsCtx, lc fx.Lifecycle, h host.Host, svc *hello.Service) { diff --git a/node/modules/storageminer.go b/node/modules/storageminer.go index 1ddbb433a..4909a8e67 100644 --- a/node/modules/storageminer.go +++ b/node/modules/storageminer.go @@ -29,21 +29,17 @@ import ( retrievalimpl "github.com/filecoin-project/go-fil-markets/retrievalmarket/impl" deals "github.com/filecoin-project/go-fil-markets/storagemarket/impl" storageimpl "github.com/filecoin-project/go-fil-markets/storagemarket/impl" + "github.com/filecoin-project/go-fil-markets/storagemarket" "github.com/filecoin-project/go-sectorbuilder" "github.com/filecoin-project/go-statestore" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" - "github.com/filecoin-project/lotus/chain/address" - "github.com/filecoin-project/lotus/chain/deals" "github.com/filecoin-project/lotus/chain/gen" - "github.com/filecoin-project/lotus/lib/sectorbuilder" - "github.com/filecoin-project/lotus/lib/statestore" "github.com/filecoin-project/lotus/miner" "github.com/filecoin-project/lotus/node/modules/dtypes" "github.com/filecoin-project/lotus/node/modules/helpers" "github.com/filecoin-project/lotus/node/repo" - "github.com/filecoin-project/go-fil-components/storagemarket" "github.com/filecoin-project/lotus/retrievaladapter" "github.com/filecoin-project/lotus/storage" "github.com/filecoin-project/lotus/storage/sectorblocks" diff --git a/storagemarketadapter/client_adapter.go b/storagemarketadapter/client_adapter.go index 8984dd882..d517c726b 100644 --- a/storagemarketadapter/client_adapter.go +++ b/storagemarketadapter/client_adapter.go @@ -5,12 +5,14 @@ package storagemarketadapter import ( "bytes" "context" + "github.com/filecoin-project/lotus/lib/sharedutils" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" - "github.com/filecoin-project/go-cbor-util" + cborutil "github.com/filecoin-project/go-cbor-util" + "github.com/filecoin-project/go-fil-markets/shared/tokenamount" sharedtypes "github.com/filecoin-project/go-fil-markets/shared/types" "github.com/filecoin-project/go-fil-markets/storagemarket" "github.com/filecoin-project/lotus/api" @@ -115,7 +117,7 @@ func (n *ClientNodeAdapter) AddFunds(ctx context.Context, addr address.Address, // (Provider Node API) smsg, err := n.MpoolPushMessage(ctx, &types.Message{ To: actors.StorageMarketAddress, - From: sharedutils.FromSharedAddress(addr), + From: addr, Value: sharedutils.FromSharedTokenAmount(amount), GasPrice: types.NewInt(0), GasLimit: types.NewInt(1000000), @@ -138,11 +140,11 @@ func (n *ClientNodeAdapter) AddFunds(ctx context.Context, addr address.Address, } func (n *ClientNodeAdapter) EnsureFunds(ctx context.Context, addr address.Address, amount tokenamount.TokenAmount) error { - return n.fm.EnsureAvailable(ctx, sharedutils.FromSharedAddress(addr), sharedutils.FromSharedTokenAmount(amount)) + return n.fm.EnsureAvailable(ctx, addr, sharedutils.FromSharedTokenAmount(amount)) } func (n *ClientNodeAdapter) GetBalance(ctx context.Context, addr address.Address) (storagemarket.Balance, error) { - bal, err := n.StateMarketBalance(ctx, sharedutils.FromSharedAddress(addr), nil) + bal, err := n.StateMarketBalance(ctx, addr, nil) if err != nil { return storagemarket.Balance{}, err } @@ -160,7 +162,7 @@ func (c *ClientNodeAdapter) ValidatePublishedDeal(ctx context.Context, deal stor return 0, xerrors.Errorf("getting deal pubsish message: %w", err) } - pw, err := stmgr.GetMinerWorker(ctx, c.sm, nil, sharedutils.FromSharedAddress(deal.Proposal.Provider)) + pw, err := stmgr.GetMinerWorker(ctx, c.sm, nil, deal.Proposal.Provider) if err != nil { return 0, xerrors.Errorf("getting miner worker failed: %w", err) } @@ -268,7 +270,7 @@ func (c *ClientNodeAdapter) OnDealSectorCommitted(ctx context.Context, provider } matchEvent := func(msg *types.Message) (bool, error) { - if msg.To != sharedutils.FromSharedAddress(provider) { + if msg.To != provider { return false, nil } @@ -304,7 +306,7 @@ func (n *ClientNodeAdapter) SignProposal(ctx context.Context, signer address.Add if err != nil { return err } - err = api.SignWith(ctx, n.Wallet.Sign, sharedutils.FromSharedAddress(signer), localProposal) + err = api.SignWith(ctx, n.Wallet.Sign, signer, localProposal) if err != nil { return err } @@ -318,13 +320,13 @@ func (n *ClientNodeAdapter) SignProposal(ctx context.Context, signer address.Add func (n *ClientNodeAdapter) GetDefaultWalletAddress(ctx context.Context) (address.Address, error) { addr, err := n.Wallet.GetDefault() - return sharedutils.ToSharedAddress(addr), err + return addr, err } func (n *ClientNodeAdapter) ValidateAskSignature(ask *sharedtypes.SignedStorageAsk) error { tss := n.cs.GetHeaviestTipSet().ParentState() - w, err := stmgr.GetMinerWorkerRaw(context.TODO(), n.StateManager, tss, sharedutils.FromSharedAddress(ask.Ask.Miner)) + w, err := stmgr.GetMinerWorkerRaw(context.TODO(), n.StateManager, tss, ask.Ask.Miner) if err != nil { return xerrors.Errorf("failed to get worker for miner in ask", err) } @@ -334,7 +336,7 @@ func (n *ClientNodeAdapter) ValidateAskSignature(ask *sharedtypes.SignedStorageA return xerrors.Errorf("failed to re-serialize ask") } - return ask.Signature.Verify(sharedutils.ToSharedAddress(w), sigb) + return ask.Signature.Verify(w, sigb) } var _ storagemarket.StorageClientNode = &ClientNodeAdapter{} diff --git a/storagemarketadapter/provider_adapter.go b/storagemarketadapter/provider_adapter.go index 0db1fde5e..a0df86096 100644 --- a/storagemarketadapter/provider_adapter.go +++ b/storagemarketadapter/provider_adapter.go @@ -47,7 +47,7 @@ func NewProviderNodeAdapter(dag dtypes.StagingDAG, secb *sectorblocks.SectorBloc func (n *ProviderNodeAdapter) PublishDeals(ctx context.Context, deal storagemarket.MinerDeal) (storagemarket.DealID, cid.Cid, error) { log.Info("publishing deal") - worker, err := n.StateMinerWorker(ctx, sharedutils.FromSharedAddress(deal.Proposal.Provider), nil) + worker, err := n.StateMinerWorker(ctx, deal.Proposal.Provider, nil) if err != nil { return 0, cid.Undef, err } @@ -151,12 +151,12 @@ func (n *ProviderNodeAdapter) ListProviderDeals(ctx context.Context, addr addres } func (n *ProviderNodeAdapter) GetMinerWorker(ctx context.Context, miner address.Address) (address.Address, error) { - addr, err := n.StateMinerWorker(ctx, sharedutils.FromSharedAddress(miner), nil) - return sharedutils.ToSharedAddress(addr), err + addr, err := n.StateMinerWorker(ctx, miner, nil) + return addr, err } func (n *ProviderNodeAdapter) SignBytes(ctx context.Context, signer address.Address, b []byte) (*sharedtypes.Signature, error) { - localSignature, err := n.WalletSign(ctx, sharedutils.FromSharedAddress(signer), b) + localSignature, err := n.WalletSign(ctx, signer, b) if err != nil { return nil, err } @@ -164,7 +164,7 @@ func (n *ProviderNodeAdapter) SignBytes(ctx context.Context, signer address.Addr } func (n *ProviderNodeAdapter) EnsureFunds(ctx context.Context, addr address.Address, amt tokenamount.TokenAmount) error { - return n.MarketEnsureAvailable(ctx, sharedutils.FromSharedAddress(addr), sharedutils.FromSharedTokenAmount(amt)) + return n.MarketEnsureAvailable(ctx, addr, sharedutils.FromSharedTokenAmount(amt)) } func (n *ProviderNodeAdapter) MostRecentStateId(ctx context.Context) (storagemarket.StateKey, error) { @@ -176,7 +176,7 @@ func (n *ProviderNodeAdapter) AddFunds(ctx context.Context, addr address.Address // (Provider Node API) smsg, err := n.MpoolPushMessage(ctx, &types.Message{ To: actors.StorageMarketAddress, - From: sharedutils.FromSharedAddress(addr), + From: addr, Value: sharedutils.FromSharedTokenAmount(amount), GasPrice: types.NewInt(0), GasLimit: types.NewInt(1000000), @@ -199,7 +199,7 @@ func (n *ProviderNodeAdapter) AddFunds(ctx context.Context, addr address.Address } func (n *ProviderNodeAdapter) GetBalance(ctx context.Context, addr address.Address) (storagemarket.Balance, error) { - bal, err := n.StateMarketBalance(ctx, sharedutils.FromSharedAddress(addr), nil) + bal, err := n.StateMarketBalance(ctx, addr, nil) if err != nil { return storagemarket.Balance{}, err } diff --git a/storagemarketadapter/utilities.go b/storagemarketadapter/utilities.go index 9b815180f..2922f9d1a 100644 --- a/storagemarketadapter/utilities.go +++ b/storagemarketadapter/utilities.go @@ -3,17 +3,18 @@ package storagemarketadapter import ( "bytes" - "github.com/filecoin-project/go-fil-components/storagemarket" + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-fil-markets/storagemarket" + "github.com/filecoin-project/lotus/chain/actors" - "github.com/filecoin-project/lotus/chain/address" "github.com/filecoin-project/lotus/lib/sharedutils" peer "github.com/libp2p/go-libp2p-peer" ) func NewStorageProviderInfo(address address.Address, miner address.Address, sectorSize uint64, peer peer.ID) storagemarket.StorageProviderInfo { return storagemarket.StorageProviderInfo{ - Address: sharedutils.ToSharedAddress(address), - Worker: sharedutils.ToSharedAddress(miner), + Address: address, + Worker: miner, SectorSize: sectorSize, PeerID: peer, } @@ -23,8 +24,8 @@ func FromOnChainDeal(deal actors.OnChainDeal) storagemarket.StorageDeal { return storagemarket.StorageDeal{ PieceRef: deal.PieceRef, PieceSize: deal.PieceSize, - Client: sharedutils.ToSharedAddress(deal.Client), - Provider: sharedutils.ToSharedAddress(deal.Provider), + Client: deal.Client, + Provider: deal.Provider, StoragePricePerEpoch: sharedutils.ToSharedTokenAmount(deal.StoragePricePerEpoch), StorageCollateral: sharedutils.ToSharedTokenAmount(deal.StorageCollateral), ActivationEpoch: deal.ActivationEpoch, @@ -35,8 +36,8 @@ func ToOnChainDeal(deal storagemarket.StorageDeal) actors.OnChainDeal { return actors.OnChainDeal{ PieceRef: deal.PieceRef, PieceSize: deal.PieceSize, - Client: sharedutils.FromSharedAddress(deal.Client), - Provider: sharedutils.FromSharedAddress(deal.Provider), + Client: deal.Client, + Provider: deal.Provider, StoragePricePerEpoch: sharedutils.FromSharedTokenAmount(deal.StoragePricePerEpoch), StorageCollateral: sharedutils.FromSharedTokenAmount(deal.StorageCollateral), ActivationEpoch: deal.ActivationEpoch,