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

[WIP] Bitswap integration in Boost #377

Closed
wants to merge 5 commits into from
Closed
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
81 changes: 81 additions & 0 deletions bitswap/bitswap_server.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package bitswap

import (
"context"
"fmt"

"github.com/filecoin-project/dagstore/shard"
"github.com/ipfs/go-cid"

logging "github.com/ipfs/go-log/v2"

exchange "github.com/ipfs/go-ipfs-exchange-interface"
"github.com/libp2p/go-libp2p-core/host"

"github.com/ipfs/go-bitswap"
nilrouting "github.com/ipfs/go-ipfs-routing/none"

"github.com/filecoin-project/dagstore"
"github.com/filecoin-project/dagstore/indexbs"
legacy_retrievalmarket "github.com/filecoin-project/go-fil-markets/retrievalmarket"
bsnetwork "github.com/ipfs/go-bitswap/network"
)

var log = logging.Logger("boost-bitswap")

type RetrievalServer struct {
dagst *dagstore.DAGStore
rp legacy_retrievalmarket.RetrievalProvider
h host.Host
bsServer exchange.Interface
}

func NewRetrievalServer(d *dagstore.DAGStore, rp legacy_retrievalmarket.RetrievalProvider, h host.Host) *RetrievalServer {
return &RetrievalServer{
dagst: d,
rp: rp,
h: h,
}
}

func (r *RetrievalServer) Start(ctx context.Context) error {
sf := indexbs.ShardSelectorF(func(c cid.Cid, shards []shard.Key) (shard.Key, error) {
for _, sk := range shards {
pieceCid, err := cid.Parse(sk.String())
if err != nil {
return shard.Key{}, fmt.Errorf("failed to parse cid")
}
b, err := r.rp.IsFreeAndUnsealed(ctx, c, pieceCid)
if err != nil {
return shard.Key{}, fmt.Errorf("failed to verify is piece is free and unsealed")
}
if b {
return sk, nil
}
}

return shard.Key{}, indexbs.ErrNoShardSelected
})

rbs, err := indexbs.NewIndexBackedBlockstore(r.dagst, sf, 100)
if err != nil {
return fmt.Errorf("failed to create index backed blockstore: %w", err)
}

// start a bitswap session on the provider
nilRouter, err := nilrouting.ConstructNilRouting(ctx, nil, nil, nil)
if err != nil {
return err
}
bsopts := []bitswap.Option{bitswap.MaxOutstandingBytesPerPeer(1 << 20)}
bsServer := bitswap.New(ctx, bsnetwork.NewFromIpfsHost(r.h, nilRouter), rbs, bsopts...)
r.bsServer = bsServer

fmt.Printf("bitswap server running on SP, addrs: %s, peerID: %s", r.h.Addrs(), r.h.ID())
log.Infow("bitswap server running on SP", "multiaddrs", r.h.Addrs(), "peerId", r.h.ID())
return nil
}

func (r *RetrievalServer) Stop(_ context.Context) error {
return r.bsServer.Close()
}
4 changes: 4 additions & 0 deletions client/deal.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"fmt"
"time"

"github.com/libp2p/go-libp2p-core/host"

"github.com/filecoin-project/boost/api"
"github.com/filecoin-project/boost/storagemarket/lp2pimpl"
"github.com/filecoin-project/boost/storagemarket/types"
Expand All @@ -22,6 +24,7 @@ import (
type StorageClient struct {
PeerStore peerstore.Peerstore
dealClient *lp2pimpl.DealClient
Host host.Host
}

func NewStorageClient(addr address.Address, fullNodeApi v1api.FullNode) (*StorageClient, error) {
Expand All @@ -43,6 +46,7 @@ func NewStorageClient(addr address.Address, fullNodeApi v1api.FullNode) (*Storag

retryOpts := lp2pimpl.RetryParameters(time.Millisecond, time.Millisecond, 1, 1)
return &StorageClient{
Host: h,
dealClient: lp2pimpl.NewDealClient(h, addr, fullNodeApi, retryOpts),
PeerStore: pstore,
}, nil
Expand Down
2 changes: 2 additions & 0 deletions cmd/boostd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ func main() {

func before(cctx *cli.Context) error {
_ = logging.SetLogLevel("boostd", "INFO")
_ = logging.SetLogLevel("boost-bitswap", "INFO")
_ = logging.SetLogLevel("dagstore-all-readblockstore", "DEBUG")

if cliutil.IsVeryVerbose {
_ = logging.SetLogLevel("boostd", "DEBUG")
Expand Down
10 changes: 6 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ require (
github.com/dustin/go-humanize v1.0.0
github.com/etclabscore/go-openrpc-reflect v0.0.36
github.com/fatih/color v1.13.0
github.com/filecoin-project/dagstore v0.5.2
github.com/filecoin-project/dagstore v0.5.3-0.20220330091151-51396854de25
github.com/filecoin-project/go-address v0.0.6
github.com/filecoin-project/go-bitfield v0.2.4
github.com/filecoin-project/go-cbor-util v0.0.1
github.com/filecoin-project/go-commp-utils v0.1.3
github.com/filecoin-project/go-data-transfer v1.15.0
github.com/filecoin-project/go-fil-commcid v0.1.0
github.com/filecoin-project/go-fil-commp-hashhash v0.1.0
github.com/filecoin-project/go-fil-markets v1.20.2-0.20220325122707-b18483a0834b
github.com/filecoin-project/go-fil-markets v1.20.2-0.20220329144844-e8c1a839f897
github.com/filecoin-project/go-jsonrpc v0.1.5
github.com/filecoin-project/go-padreader v0.0.1
github.com/filecoin-project/go-state-types v0.1.3
github.com/filecoin-project/go-statestore v0.2.0
github.com/filecoin-project/index-provider v0.5.0
github.com/filecoin-project/lotus v1.15.1-0.20220321111228-3c1edca90295
github.com/filecoin-project/index-provider v0.6.1
github.com/filecoin-project/lotus v1.15.1-0.20220330062321-65dbddcfe8c2
github.com/filecoin-project/specs-actors v0.9.14
github.com/filecoin-project/specs-actors/v2 v2.3.6
github.com/filecoin-project/specs-actors/v5 v5.0.4
Expand All @@ -43,6 +43,7 @@ require (
github.com/graph-gophers/graphql-go v1.2.0
github.com/graph-gophers/graphql-transport-ws v0.0.1
github.com/hashicorp/go-multierror v1.1.1
github.com/ipfs/go-bitswap v0.5.1
github.com/ipfs/go-block-format v0.0.3
github.com/ipfs/go-blockservice v0.2.1
github.com/ipfs/go-cid v0.1.0
Expand All @@ -56,6 +57,7 @@ require (
github.com/ipfs/go-ipfs-exchange-interface v0.1.0
github.com/ipfs/go-ipfs-exchange-offline v0.1.1
github.com/ipfs/go-ipfs-files v0.0.9
github.com/ipfs/go-ipfs-routing v0.2.1
github.com/ipfs/go-ipld-format v0.2.0
github.com/ipfs/go-log/v2 v2.5.0
github.com/ipfs/go-merkledag v0.5.1
Expand Down
28 changes: 19 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,10 @@ github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL
github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/filecoin-project/dagstore v0.5.2 h1:Nd6oXdnolbbVhpMpkYT5PJHOjQp4OBSntHpMV5pxj3c=
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/filecoin-project/dagstore v0.5.2/go.mod h1:mdqKzYrRBHf1pRMthYfMv3n37oOw0Tkx7+TxPt240M0=
github.com/filecoin-project/dagstore v0.5.3-0.20220330091151-51396854de25 h1:xaJLkFWVVhk598H7kXk010eEq9jYZrA4OXd/hP5Gu0g=
github.com/filecoin-project/dagstore v0.5.3-0.20220330091151-51396854de25/go.mod h1:s4Jn8iZmbjDOAkukS/fWBISrgUwtv1w5QDGsIXG9Fbs=
github.com/filecoin-project/go-address v0.0.3/go.mod h1:jr8JxKsYx+lQlQZmF5i2U0Z+cGQ59wMIps/8YW/lDj8=
github.com/filecoin-project/go-address v0.0.5/go.mod h1:jr8JxKsYx+lQlQZmF5i2U0Z+cGQ59wMIps/8YW/lDj8=
github.com/filecoin-project/go-address v0.0.6 h1:DWQtj38ax+ogHwyH3VULRIoT8E6loyXqsk/p81xoY7M=
Expand Down Expand Up @@ -336,8 +338,8 @@ github.com/filecoin-project/go-fil-commcid v0.1.0/go.mod h1:Eaox7Hvus1JgPrL5+M3+
github.com/filecoin-project/go-fil-commp-hashhash v0.1.0 h1:imrrpZWEHRnNqqv0tN7LXep5bFEVOVmQWHJvl2mgsGo=
github.com/filecoin-project/go-fil-commp-hashhash v0.1.0/go.mod h1:73S8WSEWh9vr0fDJVnKADhfIv/d6dCbAGaAGWbdJEI8=
github.com/filecoin-project/go-fil-markets v1.20.1/go.mod h1:QV767KIWHrikVK8R0u2wTc5wkee4gXOf5/AfxDoQckw=
github.com/filecoin-project/go-fil-markets v1.20.2-0.20220325122707-b18483a0834b h1:fiP6Ifxvaa/j+Zo0tLPY+mBl0oHb215bzCcZmzQU34Y=
github.com/filecoin-project/go-fil-markets v1.20.2-0.20220325122707-b18483a0834b/go.mod h1:QV767KIWHrikVK8R0u2wTc5wkee4gXOf5/AfxDoQckw=
github.com/filecoin-project/go-fil-markets v1.20.2-0.20220329144844-e8c1a839f897 h1:lo6b7HXFnOz/JrP9b9QhOJ3UURufeJ1Du9Aot/t/F/Y=
github.com/filecoin-project/go-fil-markets v1.20.2-0.20220329144844-e8c1a839f897/go.mod h1:Oknh4H28OpnkH+vAC+AtMmjC9sudzFNtb8Q183pPsfs=
github.com/filecoin-project/go-hamt-ipld v0.1.5 h1:uoXrKbCQZ49OHpsTCkrThPNelC4W3LPEk0OrS/ytIBM=
github.com/filecoin-project/go-hamt-ipld v0.1.5/go.mod h1:6Is+ONR5Cd5R6XZoCse1CWaXZc0Hdb/JeX+EQCQzX24=
github.com/filecoin-project/go-hamt-ipld/v2 v2.0.0 h1:b3UDemBYN2HNfk3KOXNuxgTTxlWi3xVvbQP0IT38fvM=
Expand All @@ -346,10 +348,12 @@ github.com/filecoin-project/go-hamt-ipld/v3 v3.0.1/go.mod h1:gXpNmr3oQx8l3o7qkGy
github.com/filecoin-project/go-hamt-ipld/v3 v3.1.0 h1:rVVNq0x6RGQIzCo1iiJlGFm9AGIZzeifggxtKMU7zmI=
github.com/filecoin-project/go-hamt-ipld/v3 v3.1.0/go.mod h1:bxmzgT8tmeVQA1/gvBwFmYdT8SOFUwB3ovSUfG1Ux0g=
github.com/filecoin-project/go-indexer-core v0.2.8/go.mod h1:IagNfTdFuX4057kla43PjRCn3yBuUiZgIxuA0hTUamY=
github.com/filecoin-project/go-indexer-core v0.2.9/go.mod h1:u03I3HB6ZnqCc3cm8Tq+QkTWBbfKOvNxM8K6Ny/IHRw=
github.com/filecoin-project/go-jsonrpc v0.1.5 h1:ckxqZ09ivBAVf5CSmxxrqqNHC7PJm3GYGtYKiNQ+vGk=
github.com/filecoin-project/go-jsonrpc v0.1.5/go.mod h1:XBBpuKIMaXIIzeqzO1iucq4GvbF8CxmXRFoezRh+Cx4=
github.com/filecoin-project/go-legs v0.3.7 h1:yfm7fx+iy1nPtgPEQ6kQjvhoJOVbXide50STYdy+yos=
github.com/filecoin-project/go-legs v0.3.7/go.mod h1:pgekGm8/gKY5zCtQ/qGAoSjGP92wTLFqpO3GPHeu8YU=
github.com/filecoin-project/go-legs v0.3.10 h1:B14z78do63gkxf5Br7rPnxZsZk/m9PR3Mx5aOf2WTIs=
github.com/filecoin-project/go-legs v0.3.10/go.mod h1:5psVRe2nRQDa3PDtcd+2Ud4CirxOr2DI5VsDVMq7sIk=
github.com/filecoin-project/go-padreader v0.0.0-20200903213702-ed5fae088b20/go.mod h1:mPn+LRRd5gEKNAtc+r3ScpW2JRU/pj4NBKdADYWHiak=
github.com/filecoin-project/go-padreader v0.0.1 h1:8h2tVy5HpoNbr2gBRr+WD6zV6VD6XHig+ynSGJg8ZOs=
github.com/filecoin-project/go-padreader v0.0.1/go.mod h1:VYVPJqwpsfmtoHnAmPx6MUwmrK6HIcDqZJiuZhtmfLQ=
Expand All @@ -364,17 +368,19 @@ github.com/filecoin-project/go-state-types v0.1.1/go.mod h1:ezYnPf0bNkTsDibL/psS
github.com/filecoin-project/go-state-types v0.1.3 h1:rzIJyQo5HO2ptc8Jcu8P0qTutnI7NWwTle54eAHoNO0=
github.com/filecoin-project/go-state-types v0.1.3/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g=
github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig=
github.com/filecoin-project/go-statemachine v1.0.1 h1:LQ60+JDVjMdLxXmVFM2jjontzOYnfVE7u02CXV3WKSw=
github.com/filecoin-project/go-statemachine v1.0.1/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54=
github.com/filecoin-project/go-statemachine v1.0.2-0.20220322104818-27f8fbb86dfd h1:Ykxbz+LvSCUIl2zFaaPGmF8KHXTJu9T/PymgHr7IHjs=
github.com/filecoin-project/go-statemachine v1.0.2-0.20220322104818-27f8fbb86dfd/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54=
github.com/filecoin-project/go-statestore v0.1.0/go.mod h1:LFc9hD+fRxPqiHiaqUEZOinUJB4WARkRfNl10O7kTnI=
github.com/filecoin-project/go-statestore v0.2.0 h1:cRRO0aPLrxKQCZ2UOQbzFGn4WDNdofHZoGPjfNaAo5Q=
github.com/filecoin-project/go-statestore v0.2.0/go.mod h1:8sjBYbS35HwPzct7iT4lIXjLlYyPor80aU7t7a/Kspo=
github.com/filecoin-project/go-storedcounter v0.1.0 h1:Mui6wSUBC+cQGHbDUBcO7rfh5zQkWJM/CpAZa/uOuus=
github.com/filecoin-project/go-storedcounter v0.1.0/go.mod h1:4ceukaXi4vFURIoxYMfKzaRF5Xv/Pinh2oTnoxpv+z8=
github.com/filecoin-project/index-provider v0.5.0 h1:k2C1RFvOvxmA2i8bhmkb3b4qun7RDRDzzs/y25/TwQg=
github.com/filecoin-project/index-provider v0.5.0/go.mod h1:KHVrP2vU3YuScb+fawObwTFoR882up9U07kk0ZrfP0c=
github.com/filecoin-project/lotus v1.15.1-0.20220321111228-3c1edca90295 h1:mCENEontHYNg8ze6HNJioIqwJwhThlkJ19pcjxlatfQ=
github.com/filecoin-project/lotus v1.15.1-0.20220321111228-3c1edca90295/go.mod h1:lWTkxHRmO6ir+uyMvvupnBcC0YMJXXQ+5cOdXuCyoFU=
github.com/filecoin-project/index-provider v0.6.1 h1:yVpmtm1ASl2JZMNDC6H2Fe0neYo5akYgaJJB2wlcsMU=
github.com/filecoin-project/index-provider v0.6.1/go.mod h1:iAbSQ6sUpKC4GqfUSheGnYwj9d9B+X8pPi4BV1PgwZA=
github.com/filecoin-project/lotus v1.15.1-0.20220330062321-65dbddcfe8c2 h1:ILZH1KMyHe1yAOXdyY64j4Nbs6nrbG6neh0lLHczhKA=
github.com/filecoin-project/lotus v1.15.1-0.20220330062321-65dbddcfe8c2/go.mod h1:lWTkxHRmO6ir+uyMvvupnBcC0YMJXXQ+5cOdXuCyoFU=
github.com/filecoin-project/specs-actors v0.9.13/go.mod h1:TS1AW/7LbG+615j4NsjMK1qlpAwaFsG9w0V2tg2gSao=
github.com/filecoin-project/specs-actors v0.9.14 h1:68PVstg2UB3ZsMLF+DKFTAs/YKsqhKWynkr0IqmVRQY=
github.com/filecoin-project/specs-actors v0.9.14/go.mod h1:TS1AW/7LbG+615j4NsjMK1qlpAwaFsG9w0V2tg2gSao=
Expand All @@ -398,8 +404,9 @@ github.com/filecoin-project/specs-actors/v7 v7.0.0 h1:FQN7tjt3o68hfb3qLFSJBoLMuO
github.com/filecoin-project/specs-actors/v7 v7.0.0/go.mod h1:TA5FwCna+Yi36POaT7SLKXsgEDvJwc0V/L6ZsO19B9M=
github.com/filecoin-project/specs-storage v0.2.0 h1:Y4UDv0apRQ3zI2GiPPubi8JblpUZZphEdaJUxCutfyg=
github.com/filecoin-project/specs-storage v0.2.0/go.mod h1:Tb88Zq+IBJbvAn3mS89GYj3jdRThBTE/771HCVZdRJU=
github.com/filecoin-project/storetheindex v0.3.5 h1:KoS9TvjPm6zIZfUH8atAHJbVHOO7GTP1MdTG+v0eE+Q=
github.com/filecoin-project/storetheindex v0.3.5/go.mod h1:0r3d0kSpK63O6AvLr1CjAINLi+nWD49clzcnKV+GLpI=
github.com/filecoin-project/storetheindex v0.4.0 h1:MPIDJYBknPbwBcVf+2/WEIK6LKxhZmfQGCrqKmvhFyU=
github.com/filecoin-project/storetheindex v0.4.0/go.mod h1:LIwqpXoKeGxOGEjmxPfdYVPQYoZOSI3oXMUd9XTCpjc=
github.com/filecoin-project/test-vectors/schema v0.0.5/go.mod h1:iQ9QXLpYWL3m7warwvK1JC/pTri8mnfEmKygNDqqY6E=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/flynn/noise v0.0.0-20180327030543-2492fe189ae6/go.mod h1:1i71OnUq3iUe1ma7Lr6yG6/rjvM3emb6yoL7xLFzcVQ=
Expand Down Expand Up @@ -589,6 +596,7 @@ github.com/gopherjs/gopherjs v0.0.0-20190812055157-5d271430af9f h1:KMlcu9X58lhTA
github.com/gopherjs/gopherjs v0.0.0-20190812055157-5d271430af9f/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
github.com/gorilla/handlers v1.4.2/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q=
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc=
Expand Down Expand Up @@ -937,6 +945,7 @@ github.com/ipld/go-ipld-prime/storage/bsadapter v0.0.0-20211210234204-ce2a1c70cd
github.com/ipld/go-ipld-selector-text-lite v0.0.1 h1:lNqFsQpBHc3p5xHob2KvEg/iM5dIFn6iw4L/Hh+kS1Y=
github.com/ipld/go-ipld-selector-text-lite v0.0.1/go.mod h1:U2CQmFb+uWzfIEF3I1arrDa5rwtj00PrpiwwCO+k1RM=
github.com/ipld/go-storethehash v0.0.1/go.mod h1:w8cQfWInks8lvvbQTiKbCPusU9v0sqiViBihTHbavpQ=
github.com/ipld/go-storethehash v0.0.2/go.mod h1:w8cQfWInks8lvvbQTiKbCPusU9v0sqiViBihTHbavpQ=
github.com/ipsn/go-secp256k1 v0.0.0-20180726113642-9d62b9f0bc52 h1:QG4CGBqCeuBo6aZlGAamSkxWdgWfZGeE49eUOWJPA4c=
github.com/ipsn/go-secp256k1 v0.0.0-20180726113642-9d62b9f0bc52/go.mod h1:fdg+/X9Gg4AsAIzWpEHwnqd+QY3b7lajxyjE1m4hkq4=
github.com/jackpal/gateway v1.0.5/go.mod h1:lTpwd4ACLXmpyiCTRtfiNyVnUmqT9RivzCDQetPfnjA=
Expand Down Expand Up @@ -1071,6 +1080,7 @@ github.com/libp2p/go-libp2p v0.16.0/go.mod h1:ump42BsirwAWxKzsCiFnTtN1Yc+DuPu76f
github.com/libp2p/go-libp2p v0.17.0/go.mod h1:Fkin50rsGdv5mm5BshBUtPRZknt9esfmYXBOYcwOTgw=
github.com/libp2p/go-libp2p v0.18.0-rc1/go.mod h1:RgYlH7IIWHXREimC92bw5Lg1V2R5XmSzuLHb5fTnr+8=
github.com/libp2p/go-libp2p v0.18.0-rc3/go.mod h1:WYL+Xw1iuwi6rdfzw5VIEpD+HqzYucHZ6fcUuumbI3M=
github.com/libp2p/go-libp2p v0.18.0-rc5/go.mod h1:aZPS5l84bDvCvP4jkyEUT/J6YOpUq33Fgqrs3K59mpI=
github.com/libp2p/go-libp2p v0.18.0 h1:moKKKG875KNGsCjZxTIFB75ihHiVjFeWg5I4aR1pDLk=
github.com/libp2p/go-libp2p v0.18.0/go.mod h1:+veaZ9z1SZQhmc5PW78jvnnxZ89Mgvmh4cggO11ETmw=
github.com/libp2p/go-libp2p-asn-util v0.0.0-20200825225859-85005c6cf052/go.mod h1:nRMRTab+kZuk0LnKZpxhOVH/ndsdr2Nr//Zltc/vwgo=
Expand Down
16 changes: 6 additions & 10 deletions indexprovider/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
logging "github.com/ipfs/go-log/v2"

"github.com/filecoin-project/boost/storagemarket/types"
metadata2 "github.com/filecoin-project/index-provider/metadata"
"github.com/filecoin-project/index-provider/metadata"

"github.com/filecoin-project/boost/db"
lotus_storagemarket "github.com/filecoin-project/go-fil-markets/storagemarket"
Expand Down Expand Up @@ -102,7 +102,7 @@ func (w *Wrapper) Start(ctx context.Context) {
log.Errorw("failed to migrate dagstore indices for Boost deals", "err", err)
}

w.prov.RegisterCallback(func(ctx context.Context, contextID []byte) (provider.MultihashIterator, error) {
w.prov.RegisterMultihashLister(func(ctx context.Context, contextID []byte) (provider.MultihashIterator, error) {
provideF := func(pieceCid cid.Cid) (provider.MultihashIterator, error) {
ii, err := w.dagStore.GetIterableIndexForPiece(pieceCid)
if err != nil {
Expand Down Expand Up @@ -141,16 +141,12 @@ func (w *Wrapper) Start(ctx context.Context) {
}

func (w *Wrapper) AnnounceBoostDeal(ctx context.Context, pds *types.ProviderDealState) (cid.Cid, error) {
// Announce deal to network Indexer
fm := metadata2.GraphsyncFilecoinV1Metadata{
mt := metadata.New(metadata.Bitswap{}, &metadata.GraphsyncFilecoinV1{
PieceCID: pds.ClientDealProposal.Proposal.PieceCID,
FastRetrieval: true,
VerifiedDeal: pds.ClientDealProposal.Proposal.VerifiedDeal,
}
dtm, err := fm.ToIndexerMetadata()
if err != nil {
return cid.Undef, fmt.Errorf("failed to encode indexer metadata: %w", err)
}
})

// ensure we have a connection with the full node host so that the index provider gossip sub announcements make their
// way to the filecoin bootstrapper network
if err := w.meshCreator.Connect(ctx); err != nil {
Expand All @@ -162,7 +158,7 @@ func (w *Wrapper) AnnounceBoostDeal(ctx context.Context, pds *types.ProviderDeal
return cid.Undef, fmt.Errorf("failed to get proposal cid from deal: %w", err)
}

annCid, err := w.prov.NotifyPut(ctx, propCid.Bytes(), dtm)
annCid, err := w.prov.NotifyPut(ctx, propCid.Bytes(), mt)
if err != nil {
return cid.Undef, fmt.Errorf("failed to announce deal to index provider: %w", err)
}
Expand Down
4 changes: 4 additions & 0 deletions itests/test_framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"sync"
"time"

"github.com/libp2p/go-libp2p-core/peer"

"golang.org/x/sync/errgroup"
"golang.org/x/xerrors"

Expand Down Expand Up @@ -63,6 +65,7 @@ type testFramework struct {

client *boostclient.StorageClient
boost api.Boost
boostAddrs peer.AddrInfo
fullNode lapi.FullNode
clientAddr address.Address
minerAddr address.Address
Expand Down Expand Up @@ -300,6 +303,7 @@ func (f *testFramework) start() error {
if err != nil {
return err
}
f.boostAddrs = boostAddrs
f.client.PeerStore.AddAddrs(boostAddrs.ID, boostAddrs.Addrs, time.Hour)

// Add boost libp2p to chain
Expand Down
9 changes: 9 additions & 0 deletions node/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"fmt"
"time"

"github.com/filecoin-project/boost/bitswap"

"github.com/filecoin-project/boost/indexprovider"
"github.com/filecoin-project/boost/storagemarket/dealfilter"

Expand Down Expand Up @@ -149,6 +151,9 @@ const (
// index-provider should be started after Boost
HandleIndexProviderKey

// Bitswap server should be started in the end
HandleBitswapServerKey

// daemon
ExtractApiKey
HeadMetricsKey
Expand Down Expand Up @@ -490,6 +495,10 @@ func ConfigBoost(c interface{}) Option {
Override(HandleBoostDealsKey, modules.HandleBoostDeals),
Override(HandleIndexProviderKey, modules.HandleIndexProvider),

// Bitswap Server
Override(new(*bitswap.RetrievalServer), bitswap.NewRetrievalServer),
Override(HandleBitswapServerKey, modules.HandleBitswapServer),

// Boost storage deal filter
Override(new(dtypes.StorageDealFilter), modules.BasicDealFilter(cfg.Dealmaking, nil)),
If(cfg.Dealmaking.Filter != "",
Expand Down
13 changes: 13 additions & 0 deletions node/modules/storageminer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"strings"
"time"

"github.com/filecoin-project/boost/bitswap"

"github.com/filecoin-project/boost/indexprovider"

"github.com/filecoin-project/boost/db"
Expand Down Expand Up @@ -484,6 +486,17 @@ func HandleBoostDeals(lc fx.Lifecycle, h host.Host, prov *storagemarket.Provider
})
}

func HandleBitswapServer(lc fx.Lifecycle, bs *bitswap.RetrievalServer) {
lc.Append(fx.Hook{
OnStart: func(ctx context.Context) error {
return bs.Start(ctx)
},
OnStop: func(ctx context.Context) error {
return bs.Stop(ctx)
},
})
}

func HandleIndexProvider(lc fx.Lifecycle, prov *indexprovider.Wrapper) {
lc.Append(fx.Hook{
OnStart: func(ctx context.Context) error {
Expand Down