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

feat(graphsync): mount the graphsync libp2p protocol #6892

Merged
merged 2 commits into from
Feb 26, 2020
Merged
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
16 changes: 9 additions & 7 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/ipfs/go-ipfs-pinner"

bserv "github.com/ipfs/go-blockservice"
"github.com/ipfs/go-graphsync"
bstore "github.com/ipfs/go-ipfs-blockstore"
exchange "github.com/ipfs/go-ipfs-exchange-interface"
"github.com/ipfs/go-ipfs-provider"
Expand Down Expand Up @@ -81,13 +82,14 @@ type IpfsNode struct {
RecordValidator record.Validator

// Online
PeerHost p2phost.Host `optional:"true"` // the network host (server+client)
Bootstrapper io.Closer `optional:"true"` // the periodic bootstrapper
Routing routing.Routing `optional:"true"` // the routing system. recommend ipfs-dht
Exchange exchange.Interface // the block exchange + strategy (bitswap)
Namesys namesys.NameSystem // the name system, resolves paths to hashes
Provider provider.System // the value provider system
IpnsRepub *ipnsrp.Republisher `optional:"true"`
PeerHost p2phost.Host `optional:"true"` // the network host (server+client)
Bootstrapper io.Closer `optional:"true"` // the periodic bootstrapper
Routing routing.Routing `optional:"true"` // the routing system. recommend ipfs-dht
Exchange exchange.Interface // the block exchange + strategy (bitswap)
Namesys namesys.NameSystem // the name system, resolves paths to hashes
Provider provider.System // the value provider system
IpnsRepub *ipnsrp.Republisher `optional:"true"`
GraphExchange graphsync.GraphExchange `optional:"true"`

AutoNAT *autonat.AutoNATService `optional:"true"`
PubSub *pubsub.PubSub `optional:"true"`
Expand Down
27 changes: 27 additions & 0 deletions core/node/graphsync.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package node

import (
"github.com/ipfs/go-graphsync"
gsimpl "github.com/ipfs/go-graphsync/impl"
"github.com/ipfs/go-graphsync/ipldbridge"
"github.com/ipfs/go-graphsync/network"
"github.com/ipfs/go-graphsync/storeutil"
"github.com/ipfs/go-ipfs-blockstore"
libp2p "github.com/libp2p/go-libp2p-core"
"go.uber.org/fx"

"github.com/ipfs/go-ipfs/core/node/helpers"
)

// Graphsync constructs a graphsync
func Graphsync(lc fx.Lifecycle, mctx helpers.MetricsCtx, host libp2p.Host, bs blockstore.GCBlockstore) graphsync.GraphExchange {
ctx := helpers.LifecycleCtx(mctx, lc)

network := network.NewFromLibp2pHost(host)
ipldBridge := ipldbridge.NewIPLDBridge()
return gsimpl.New(ctx,
network, ipldBridge,
storeutil.LoaderForBlockstore(bs),
storeutil.StorerForBlockstore(bs),
)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
1 change: 1 addition & 0 deletions core/node/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ func Online(bcfg *BuildCfg, cfg *config.Config) fx.Option {

return fx.Options(
fx.Provide(OnlineExchange(shouldBitswapProvide)),
maybeProvide(Graphsync, cfg.Experimental.GraphsyncEnabled),
fx.Provide(Namesys(ipnsCacheSize)),

fx.Invoke(IpnsRepublisher(repubPeriod, recordLifetime)),
Expand Down
28 changes: 28 additions & 0 deletions docs/experimental-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ the above issue.
- [AutoRelay](#autorelay)
- [TLS 1.3 Handshake](#tls-13-as-default-handshake-protocol)
- [Strategic Providing](#strategic-providing)
- [Graphsync](graphsync)

---

Expand Down Expand Up @@ -705,3 +706,30 @@ ipfs config --json Experimental.StrategicProviding true
- [ ] provide roots
- [ ] provide all
- [ ] provide strategic

## GraphSync

### State

Experimental, disabled by default.

[GraphSync](https://github.com/ipfs/go-graphsync) is the next-gen graph exchange
protocol for IPFS.

When this feature is enabled, IPFS will make files available over the graphsync
protocol. However, IPFS will not currently use this protocol to _fetch_ files.

### How to enable

Modify your ipfs config:

```
ipfs config --json Experimental.GraphsyncEnabled true
```

### Road to being a real feature

- [ ] We need to confirm that it can't be used to DoS a node. The server-side
logic for GraphSync is quite complex and, if we're not careful, the server
might end up performing unbounded work when responding to a malicious
request.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ require (
github.com/ipfs/go-ds-measure v0.1.0
github.com/ipfs/go-filestore v0.0.3
github.com/ipfs/go-fs-lock v0.0.4
github.com/ipfs/go-graphsync v0.0.4
github.com/ipfs/go-ipfs-blockstore v0.1.4
github.com/ipfs/go-ipfs-chunker v0.0.4
github.com/ipfs/go-ipfs-cmds v0.1.1
github.com/ipfs/go-ipfs-config v0.2.0
github.com/ipfs/go-ipfs-config v0.2.1
github.com/ipfs/go-ipfs-ds-help v0.1.1
github.com/ipfs/go-ipfs-exchange-interface v0.0.1
github.com/ipfs/go-ipfs-exchange-offline v0.0.1
Expand Down
33 changes: 29 additions & 4 deletions go.sum

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions test/bin/Rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ $(d)/go-sleep: github.com/ipfs/go-ipfs/test/dependencies/go-sleep
$(go-build-testdep)
TGTS_$(d) += $(d)/go-sleep

.PHONY: github.com/ipfs/go-ipfs/test/dependencies/graphsync-get
$(d)/graphsync-get: github.com/ipfs/go-ipfs/test/dependencies/graphsync-get
$(go-build-testdep)
TGTS_$(d) += $(d)/graphsync-get

.PHONY: github.com/ipfs/go-ipfs/test/dependencies/go-timeout
$(d)/go-timeout: github.com/ipfs/go-ipfs/test/dependencies/go-timeout
$(go-build-testdep)
Expand Down
23 changes: 16 additions & 7 deletions test/dependencies/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,26 @@ go 1.13
require (
github.com/Kubuxu/gocovmerge v0.0.0-20161216165753-7ecaa51963cd
github.com/golangci/golangci-lint v1.18.0
github.com/ipfs/go-blockservice v0.1.2
github.com/ipfs/go-cid v0.0.5
github.com/ipfs/go-cidutil v0.0.2
github.com/ipfs/go-log v0.0.1
github.com/ipfs/go-datastore v0.4.4
github.com/ipfs/go-graphsync v0.0.4
github.com/ipfs/go-ipfs-blockstore v1.0.0
github.com/ipfs/go-ipfs-exchange-offline v0.0.1
github.com/ipfs/go-log v1.0.2
github.com/ipfs/go-merkledag v0.3.1
github.com/ipfs/go-unixfs v0.2.4
github.com/ipfs/hang-fds v0.0.1
github.com/ipfs/iptb v1.4.0
github.com/ipfs/iptb-plugins v0.2.0
github.com/ipfs/iptb-plugins v0.2.1
github.com/ipld/go-ipld-prime v0.0.2-0.20191108012745-28a82f04c785
github.com/jbenet/go-random v0.0.0-20190219211222-123a90aedc0c
github.com/jbenet/go-random-files v0.0.0-20190219210431-31b3f20ebded
github.com/multiformats/go-multiaddr v0.0.4
github.com/multiformats/go-multiaddr-net v0.0.1
github.com/multiformats/go-multihash v0.0.7
github.com/ultraware/funlen v0.0.2 // indirect
golang.org/x/tools v0.0.0-20190912185636-87d9f09c5d89 // indirect
github.com/libp2p/go-libp2p v0.5.2
github.com/libp2p/go-libp2p-core v0.3.1
github.com/multiformats/go-multiaddr v0.2.0
github.com/multiformats/go-multiaddr-net v0.1.2
github.com/multiformats/go-multihash v0.0.13
gotest.tools/gotestsum v0.3.5
)
Loading