Skip to content

Commit 5c13117

Browse files
committed
curio migration command
1 parent cf25787 commit 5c13117

File tree

23 files changed

+1160
-100
lines changed

23 files changed

+1160
-100
lines changed

.github/image/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ RUN git submodule update --init
1818
RUN go mod download
1919

2020
# Download Go dependencies for Curio
21-
WORKDIR /app/boost
21+
WORKDIR /app/curio
2222
RUN git submodule update --init
2323
RUN go mod download
2424

2525
# Stage 2: Install Lotus binary
26-
FROM ghcr.io/filecoin-shipyard/lotus-containers:lotus-v1.32.1-devnet AS lotus-test
26+
FROM ghcr.io/filecoin-shipyard/lotus-containers:lotus-v1.32.2-devnet AS lotus-test
2727

2828
# Stage 3: Build the final image
2929
FROM myoung34/github-runner AS curio-github-runner

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
/booster-bitswap
99
/docgen-md
1010
/docgen-openrpc
11+
/migrate-curio
1112
extern/filecoin-ffi/rust/target
1213
extern/boostd-data/boostd-data
1314
**/*.a

Makefile

+8-2
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ boostci: $(BUILD_DEPS)
133133
$(GOCC) build $(GOFLAGS) -o boostci ./cmd/boostci
134134
.PHONY: boostci
135135

136+
migrate-curio: $(BUILD_DEPS)
137+
rm -f migrate-curio
138+
$(GOCC) build $(GOFLAGS) -o migrate-curio ./cmd/migrate-curio
139+
.PHONY: boostci
140+
136141
react: validate-node-version
137142
npm_config_legacy_peer_deps=yes npm ci --no-audit --prefix react
138143
npm run --prefix react build
@@ -143,7 +148,7 @@ update-react: validate-node-version
143148
npm run --prefix react build
144149
.PHONY: react
145150

146-
build-go: boost boostd boostx boostd-data booster-http booster-bitswap devnet migrate-lid
151+
build-go: boost boostd boostx boostd-data booster-http booster-bitswap devnet migrate-lid migrate-curio
147152
.PHONY: build-go
148153

149154
build: react build-go
@@ -162,6 +167,7 @@ install-boost:
162167
install -C ./booster-http /usr/local/bin/booster-http
163168
install -C ./booster-bitswap /usr/local/bin/booster-bitswap
164169
install -C ./migrate-lid /usr/local/bin/migrate-lid
170+
install -C ./migrate-curio /usr/local/bin/migrate-curio
165171

166172
install-devnet:
167173
install -C ./devnet /usr/local/bin/devnet
@@ -217,7 +223,7 @@ docsgen-openrpc-boost: docsgen-openrpc-bin
217223

218224
## DOCKER IMAGES
219225
docker_user?=filecoin
220-
lotus_version?=v1.32.1
226+
lotus_version?=v1.32.2
221227
ffi_from_source?=0
222228
build_lotus?=0
223229
ifeq ($(build_lotus),1)

api/api.go

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type Boost interface {
2626
Net
2727

2828
// MethodGroup: Boost
29+
BoostIndexerRemoveAll(ctx context.Context) ([]cid.Cid, error) //perm:admin
2930
BoostIndexerAnnounceAllDeals(ctx context.Context) error //perm:admin
3031
BoostIndexerListMultihashes(ctx context.Context, contextID []byte) ([]multihash.Multihash, error) //perm:admin
3132
BoostIndexerAnnounceLatest(ctx context.Context) (cid.Cid, error) //perm:admin

api/proxy_gen.go

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/openrpc/boost.json.gz

63 Bytes
Binary file not shown.

cmd/boostd/index.go

+27
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ var indexProvCmd = &cli.Command{
2222
indexProvAnnounceLatestHttp,
2323
indexProvAnnounceDealRemovalAd,
2424
indexProvAnnounceDeal,
25+
indexProvRemoveAllCmd,
2526
},
2627
}
2728

@@ -303,3 +304,29 @@ var indexProvAnnounceDeal = &cli.Command{
303304
return nil
304305
},
305306
}
307+
308+
var indexProvRemoveAllCmd = &cli.Command{
309+
Name: "remove-all",
310+
Usage: "Announce all removal ad for all contextIDs",
311+
Flags: []cli.Flag{},
312+
Action: func(cctx *cli.Context) error {
313+
ctx := lcli.ReqContext(cctx)
314+
315+
// get boost api
316+
napi, closer, err := bcli.GetBoostAPI(cctx)
317+
if err != nil {
318+
return err
319+
}
320+
defer closer()
321+
322+
// announce markets and boost deals
323+
cids, err := napi.BoostIndexerRemoveAll(ctx)
324+
if err != nil {
325+
return err
326+
}
327+
for _, c := range cids {
328+
fmt.Println("Published the removal ad with CID", c.String())
329+
}
330+
return nil
331+
},
332+
}

cmd/booster-bitswap/client.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/ipld/go-ipld-prime"
1414
cidlink "github.com/ipld/go-ipld-prime/linking/cid"
1515
"github.com/ipld/go-ipld-prime/traversal"
16+
nilrouting "github.com/libp2p/go-libp2p-routing-helpers"
1617
"github.com/libp2p/go-libp2p/core/host"
1718
mh "github.com/multiformats/go-multihash"
1819

@@ -21,7 +22,6 @@ import (
2122
lcli "github.com/filecoin-project/lotus/cli"
2223
"github.com/ipfs/boxo/bitswap/client"
2324
bsnetwork "github.com/ipfs/boxo/bitswap/network"
24-
nilrouting "github.com/ipfs/boxo/routing/none"
2525
blocks "github.com/ipfs/go-block-format"
2626
"github.com/ipfs/go-cid"
2727
ipldlegacy "github.com/ipfs/go-ipld-legacy"
@@ -96,10 +96,7 @@ var fetchCmd = &cli.Command{
9696
}
9797

9898
// Create a bitswap client
99-
nilRouter, err := nilrouting.ConstructNilRouting(ctx, nil, nil, nil)
100-
if err != nil {
101-
return err
102-
}
99+
nilRouter := nilrouting.Null{}
103100
net := bsnetwork.NewFromIpfsHost(host, nilRouter)
104101
bs, err := blockstore.OpenReadWrite(outputCarPath, []cid.Cid{rootCid}, blockstore.UseWholeCIDs(true))
105102
if err != nil {

cmd/booster-bitswap/server.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import (
88
"github.com/filecoin-project/boost/protocolproxy"
99
bsnetwork "github.com/ipfs/boxo/bitswap/network"
1010
"github.com/ipfs/boxo/bitswap/server"
11-
blockstore "github.com/ipfs/boxo/blockstore"
12-
nilrouting "github.com/ipfs/boxo/routing/none"
11+
"github.com/ipfs/boxo/blockstore"
1312
"github.com/ipfs/go-cid"
13+
nilrouting "github.com/libp2p/go-libp2p-routing-helpers"
1414
"github.com/libp2p/go-libp2p/core/host"
1515
"github.com/libp2p/go-libp2p/core/peer"
1616
)
@@ -66,10 +66,7 @@ func (s *BitswapServer) Start(ctx context.Context, proxy *peer.AddrInfo, opts *B
6666
}
6767

6868
// Start a bitswap server on the provider
69-
nilRouter, err := nilrouting.ConstructNilRouting(s.ctx, nil, nil, nil)
70-
if err != nil {
71-
return err
72-
}
69+
nilRouter := nilrouting.Null{}
7370
bsopts := []server.Option{
7471
server.EngineBlockstoreWorkerCount(opts.EngineBlockstoreWorkerCount),
7572
server.EngineTaskWorkerCount(opts.EngineTaskWorkerCount),

cmd/migrate-curio/leveldb.go

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/urfave/cli/v2"
7+
)
8+
9+
var cleanupLevelDBCmd = &cli.Command{
10+
Name: "leveldb",
11+
Description: "Removes the indexes and other metadata leveldb based LID store",
12+
Usage: "migrate-curio cleanup leveldb",
13+
Before: before,
14+
Action: func(cctx *cli.Context) error {
15+
fmt.Println("Please remove the directory called 'LID' in the boost repo path to remove leveldb based LID")
16+
fmt.Println("This directory can also be present outside of Boost repo if 'boostd-data' was running with a custom repo path")
17+
return nil
18+
},
19+
}

cmd/migrate-curio/main.go

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
package main
2+
3+
import (
4+
"os"
5+
6+
"github.com/filecoin-project/boost/build"
7+
logging "github.com/ipfs/go-log/v2"
8+
"github.com/urfave/cli/v2"
9+
)
10+
11+
var log = logging.Logger("migrate-curio")
12+
13+
const (
14+
FlagBoostRepo = "boost-repo"
15+
)
16+
17+
var FlagRepo = &cli.StringFlag{
18+
Name: FlagBoostRepo,
19+
EnvVars: []string{"BOOST_PATH"},
20+
Usage: "boost repo path",
21+
Value: "~/.boost",
22+
}
23+
24+
var IsVeryVerbose bool
25+
26+
var FlagVeryVerbose = &cli.BoolFlag{
27+
Name: "vv",
28+
Usage: "enables very verbose mode, useful for debugging the CLI",
29+
Destination: &IsVeryVerbose,
30+
}
31+
32+
func main() {
33+
app := &cli.App{
34+
Name: "migrate-curio",
35+
Usage: "Migrate boost to Curio",
36+
EnableBashCompletion: true,
37+
Version: build.UserVersion(),
38+
Flags: []cli.Flag{
39+
FlagRepo,
40+
FlagVeryVerbose,
41+
&cli.StringFlag{
42+
Name: "db-host",
43+
EnvVars: []string{"CURIO_DB_HOST", "CURIO_HARMONYDB_HOSTS"},
44+
Usage: "Command separated list of hostnames for yugabyte cluster",
45+
Value: "127.0.0.1",
46+
},
47+
&cli.StringFlag{
48+
Name: "db-name",
49+
EnvVars: []string{"CURIO_DB_NAME", "CURIO_HARMONYDB_NAME"},
50+
Value: "yugabyte",
51+
},
52+
&cli.StringFlag{
53+
Name: "db-user",
54+
EnvVars: []string{"CURIO_DB_USER", "CURIO_HARMONYDB_USERNAME"},
55+
Value: "yugabyte",
56+
},
57+
&cli.StringFlag{
58+
Name: "db-password",
59+
EnvVars: []string{"CURIO_DB_PASSWORD", "CURIO_HARMONYDB_PASSWORD"},
60+
Value: "yugabyte",
61+
},
62+
&cli.StringFlag{
63+
Name: "db-port",
64+
EnvVars: []string{"CURIO_DB_PORT", "CURIO_HARMONYDB_PORT"},
65+
Value: "5433",
66+
},
67+
},
68+
Commands: []*cli.Command{
69+
migrateCmd,
70+
cleanupLIDCmd,
71+
},
72+
}
73+
app.Setup()
74+
75+
if err := app.Run(os.Args); err != nil {
76+
os.Stderr.WriteString("Error: " + err.Error() + "\n")
77+
}
78+
}
79+
80+
func before(cctx *cli.Context) error {
81+
_ = logging.SetLogLevel("migrate-curio", "INFO")
82+
83+
if IsVeryVerbose {
84+
_ = logging.SetLogLevel("migrate-curio", "DEBUG")
85+
}
86+
87+
return nil
88+
}

0 commit comments

Comments
 (0)