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: switch to boxo and use routing-v1 for routing requests #4

Merged
merged 1 commit into from
Oct 4, 2023

Conversation

aschmahmann
Copy link
Contributor

@aschmahmann aschmahmann commented Oct 3, 2023

Unarchived the repo and simplified the code by switching to the boxo gateway implementation.

Some notable changes:

  1. Switched from an accelerated DHT client to a routing-v1 backend. Could support both if desired though.
  2. Switched from a Bitswap Client + Server to just a Client

Some smaller ones which anyone should feel free to revert:

  • Reduced the low water defaults (no evidence gathered here, but since we're not running the accelerated client it seems like we should safely be able to reduce some limits). Lower numbers of connections will also help us out with reducing unnecessary spamming from the boxo/bitswap client until that's resolved.
  • Changed the tagline. Figured the experimental thing shouldn't be advertised as "just working" until we've shown it doing the job 😅
  • Changed the version to v0.0.1-dev
  • Changed the wording around the /version endpoint

Other notes:

  • rainbow previously did GC via a special API. We could also experiment with other types of GC (e.g. LRU, LFRU, etc.) but didn't feel the need to change this here.
  • similarly, rainbow uses flatfs which is another area that can be examined for what makes sense

@aschmahmann aschmahmann force-pushed the feat/boxo-with-routing-v1 branch 2 times, most recently from 8670a09 to 517dcde Compare October 3, 2023 21:35
@hacdias
Copy link
Member

hacdias commented Oct 4, 2023

Since I don't have permissions in this repository: ✅ I do approve. My feedback:

diff --git a/.gitignore b/.gitignore
index b74c25d..c718cb0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
 rainbow
 libp2p.key
+blockstore
+datastore
diff --git a/main.go b/main.go
index 5b11d60..58a0183 100644
--- a/main.go
+++ b/main.go
@@ -98,8 +98,6 @@ func main() {
 					http.Error(w, err.Error(), http.StatusInternalServerError)
 					return
 				}
-
-				return
 			})
 
 			if err := http.ListenAndServe(cctx.String("api-listen"), nil); err != nil {
diff --git a/setup.go b/setup.go
index e6b3541..314fdc9 100644
--- a/setup.go
+++ b/setup.go
@@ -4,8 +4,6 @@ import (
 	"context"
 	crand "crypto/rand"
 	"fmt"
-	httpcontentrouter "github.com/ipfs/boxo/routing/http/contentrouter"
-	"io/ioutil"
 	"net/http"
 	"os"
 	"time"
@@ -14,10 +12,10 @@ import (
 	bsnet "github.com/ipfs/boxo/bitswap/network"
 	"github.com/ipfs/boxo/blockservice"
 	blockstore "github.com/ipfs/boxo/blockstore"
-	bstore "github.com/ipfs/boxo/blockstore"
 	"github.com/ipfs/boxo/gateway"
 	"github.com/ipfs/boxo/namesys"
 	routingv1client "github.com/ipfs/boxo/routing/http/client"
+	httpcontentrouter "github.com/ipfs/boxo/routing/http/contentrouter"
 	flatfs "github.com/ipfs/go-ds-flatfs"
 	levelds "github.com/ipfs/go-ds-leveldb"
 	logging "github.com/ipfs/go-log/v2"
@@ -54,8 +52,6 @@ type Node struct {
 	ns namesys.NameSystem
 
 	bwc *metrics.BandwidthCounter
-
-	mux *http.ServeMux
 }
 
 type Config struct {
@@ -121,7 +117,7 @@ func Setup(ctx context.Context, cfg *Config) (*Node, error) {
 	if err != nil {
 		return nil, err
 	}
-	blkst = bstore.NewIdStore(blkst)
+	blkst = blockstore.NewIdStore(blkst)
 
 	bsctx := metri.CtxScope(ctx, "rainbow")
 
@@ -187,7 +183,7 @@ func loadBlockstore(spec string, path string) (blockstore.Blockstore, error) {
 }
 
 func loadOrInitPeerKey(kf string) (crypto.PrivKey, error) {
-	data, err := ioutil.ReadFile(kf)
+	data, err := os.ReadFile(kf)
 	if err != nil {
 		if !os.IsNotExist(err) {
 			return nil, err

Removes duplicate dependencies, adds blockstore and datastore to .gitignore, and stops using deprecated APIs.

@aschmahmann
Copy link
Contributor Author

Thanks @hacdias, updated with your fixes as well as a couple of bugs I found and copying the version-ing scheme from bifrost-gateway for now. Will make a follow-up PR on this one with more things like tracing.

Will also get permissions sorted out on this repo 😅

@aschmahmann aschmahmann merged commit 0f71324 into master Oct 4, 2023
@aschmahmann aschmahmann deleted the feat/boxo-with-routing-v1 branch October 4, 2023 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants