Skip to content

Commit e73af16

Browse files
authored
fix: refactor LID clean up (#1886)
* refactor pdcleaner * move cleanup test to itest * increase blocktime * use evemtually and errgroup * fix lint errs * bump container lotus version * bump image builder go version * bump docker node rust versions
1 parent b30e28d commit e73af16

File tree

15 files changed

+560
-404
lines changed

15 files changed

+560
-404
lines changed

.circleci/config.yml

+5
Original file line numberDiff line numberDiff line change
@@ -363,4 +363,9 @@ workflows:
363363
suite: booster-bitswap
364364
target: "./cmd/booster-bitswap"
365365

366+
- test:
367+
name: test-itest-lid-cleanup
368+
suite: itest-lid-cleanup
369+
target: "./itests/lid_cleanup_test.go"
370+
366371
- lid-docker-compose

.github/workflows/container-build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
contents: read
1717
packages: write
1818
env:
19-
LOTUS_VERSION: 'v1.23.3'
19+
LOTUS_VERSION: 'v1.26.0-rc1'
2020
LOTUS_SOURCE_IMAGE: 'ghcr.io/filecoin-shipyard/lotus-containers:lotus'
2121
NETWORK_NAME: 'devnet'
2222
FFI_BUILD_FROM_SOURCE: '0'

api/api.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type Boost interface {
2727

2828
// MethodGroup: Boost
2929
BoostIndexerAnnounceAllDeals(ctx context.Context) error //perm:admin
30-
BoostIndexerListMultihashes(ctx context.Context, proposalCid cid.Cid) ([]multihash.Multihash, error) //perm:admin
30+
BoostIndexerListMultihashes(ctx context.Context, contextID []byte) ([]multihash.Multihash, error) //perm:admin
3131
BoostIndexerAnnounceLatest(ctx context.Context) (cid.Cid, error) //perm:admin
3232
BoostIndexerAnnounceLatestHttp(ctx context.Context, urls []string) (cid.Cid, error) //perm:admin
3333
BoostOfflineDealWithData(ctx context.Context, dealUuid uuid.UUID, filePath string, delAfterImport bool) (*ProviderDealRejectionInfo, error) //perm:admin
@@ -48,6 +48,7 @@ type Boost interface {
4848
// MethodGroup: PieceDirectory
4949
PdBuildIndexForPieceCid(ctx context.Context, piececid cid.Cid) error //perm:admin
5050
PdRemoveDealForPiece(ctx context.Context, piececid cid.Cid, dealID string) error //perm:admin
51+
PdCleanup(ctx context.Context) error //perm:admin
5152

5253
// MethodGroup: Misc
5354
OnlineBackup(context.Context, string) error //perm:admin

api/proxy_gen.go

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

build/openrpc/boost.json.gz

40 Bytes
Binary file not shown.

cmd/boostd/index.go

+40-11
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
lcli "github.com/filecoin-project/lotus/cli"
99
"github.com/google/uuid"
1010
"github.com/ipfs/go-cid"
11+
"github.com/multiformats/go-multihash"
1112
"github.com/urfave/cli/v2"
1213
)
1314

@@ -45,16 +46,11 @@ var indexProvAnnounceAllCmd = &cli.Command{
4546

4647
var indexProvListMultihashesCmd = &cli.Command{
4748
Name: "list-multihashes",
48-
Usage: "list-multihashes <proposal cid>",
49-
UsageText: "List multihashes for a deal by proposal cid",
49+
Usage: "list-multihashes <proposal cid / deal UUID>",
50+
UsageText: "List multihashes for a deal by proposal cid or deal UUID",
5051
Action: func(cctx *cli.Context) error {
5152
if cctx.NArg() != 1 {
52-
return fmt.Errorf("must supply proposal cid")
53-
}
54-
55-
propCid, err := cid.Parse(cctx.Args().First())
56-
if err != nil {
57-
return fmt.Errorf("parsing proposal cid %s: %w", cctx.Args().First(), err)
53+
return fmt.Errorf("must supply a proposal cid or deal UUID")
5854
}
5955

6056
ctx := lcli.ReqContext(cctx)
@@ -66,13 +62,46 @@ var indexProvListMultihashesCmd = &cli.Command{
6662
}
6763
defer closer()
6864

69-
// get list of multihashes
70-
mhs, err := napi.BoostIndexerListMultihashes(ctx, propCid)
65+
if cctx.Args().Len() != 1 {
66+
return fmt.Errorf("must specify only one proposal CID / deal UUID")
67+
}
68+
69+
id := cctx.Args().Get(0)
70+
71+
var proposalCid cid.Cid
72+
var mhs []multihash.Multihash
73+
dealUuid, err := uuid.Parse(id)
74+
if err != nil {
75+
propCid, err := cid.Decode(id)
76+
if err != nil {
77+
return fmt.Errorf("could not parse '%s' as deal uuid or proposal cid", id)
78+
}
79+
proposalCid = propCid
80+
}
81+
82+
if !proposalCid.Defined() {
83+
contextID, err := dealUuid.MarshalBinary()
84+
if err != nil {
85+
return fmt.Errorf("parsing UUID to bytes: %w", err)
86+
}
87+
mhs, err = napi.BoostIndexerListMultihashes(ctx, contextID)
88+
if err != nil {
89+
return err
90+
}
91+
fmt.Printf("Found %d multihashes for deal with ID %s:\n", len(mhs), id)
92+
for _, mh := range mhs {
93+
fmt.Println(" " + mh.String())
94+
}
95+
96+
return nil
97+
}
98+
99+
mhs, err = napi.BoostIndexerListMultihashes(ctx, proposalCid.Bytes())
71100
if err != nil {
72101
return err
73102
}
74103

75-
fmt.Printf("Found %d multihashes for deal with proposal cid %s:\n", len(mhs), propCid)
104+
fmt.Printf("Found %d multihashes for deal with ID %s:\n", len(mhs), id)
76105
for _, mh := range mhs {
77106
fmt.Println(" " + mh.String())
78107
}

cmd/boostd/piecedir.go

+22
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ var pieceDirCmd = &cli.Command{
1919
pdIndexGenerate,
2020
recoverCmd,
2121
removeDealCmd,
22+
lidCleanupCmd,
2223
},
2324
}
2425

@@ -109,3 +110,24 @@ var removeDealCmd = &cli.Command{
109110

110111
},
111112
}
113+
114+
var lidCleanupCmd = &cli.Command{
115+
Name: "cleanup",
116+
Usage: "Triggers a cleanup for LID. Command will wait for existing cleanup jobs to finish if there are any",
117+
Action: func(cctx *cli.Context) error {
118+
ctx := lcli.ReqContext(cctx)
119+
120+
napi, closer, err := bcli.GetBoostAPI(cctx)
121+
if err != nil {
122+
return err
123+
}
124+
defer closer()
125+
126+
err = napi.PdCleanup(ctx)
127+
if err != nil {
128+
return fmt.Errorf("clean up failed: %w", err)
129+
}
130+
fmt.Println("LID clean up complete")
131+
return nil
132+
},
133+
}

docker/devnet/Dockerfile.source

+8-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
ARG LOTUS_TEST_IMAGE=filecoin/lotus-test:latest
55
FROM ${LOTUS_TEST_IMAGE} as lotus-test
66
#########################################################################################
7-
FROM node:16.16-alpine3.15 AS react-builder
7+
FROM node:20.11.1-alpine3.19 AS react-builder
88

99
WORKDIR /src
1010
COPY react /src/react
@@ -13,7 +13,7 @@ COPY gql /src/gql
1313
RUN npm_config_legacy_peer_deps=yes npm ci --no-audit --prefix react&& \
1414
npm run --prefix react build
1515
#########################################################################################
16-
FROM golang:1.20-bullseye as builder
16+
FROM golang:1.21-bullseye as builder
1717

1818
RUN apt update && apt install -y \
1919
build-essential \
@@ -31,16 +31,18 @@ RUN apt update && apt install -y \
3131
ENV RUSTUP_HOME=/usr/local/rustup \
3232
CARGO_HOME=/usr/local/cargo \
3333
PATH=/usr/local/cargo/bin:$PATH \
34-
RUST_VERSION=1.63.0
34+
RUST_VERSION=1.76.0
3535

3636
RUN set -eux; \
3737
dpkgArch="$(dpkg --print-architecture)"; \
3838
case "${dpkgArch##*-}" in \
39-
amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='5cc9ffd1026e82e7fb2eec2121ad71f4b0f044e88bca39207b3f6b769aaa799c' ;; \
40-
arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='e189948e396d47254103a49c987e7fb0e5dd8e34b200aa4481ecc4b8e41fb929' ;; \
39+
amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='0b2f6c8f85a3d02fde2efc0ced4657869d73fccfce59defb4e8d29233116e6db' ;; \
40+
armhf) rustArch='armv7-unknown-linux-gnueabihf'; rustupSha256='f21c44b01678c645d8fbba1e55e4180a01ac5af2d38bcbd14aa665e0d96ed69a' ;; \
41+
arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='673e336c81c65e6b16dcdede33f4cc9ed0f08bde1dbe7a935f113605292dc800' ;; \
42+
i386) rustArch='i686-unknown-linux-gnu'; rustupSha256='e7b0f47557c1afcd86939b118cbcf7fb95a5d1d917bdd355157b63ca00fc4333' ;; \
4143
*) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \
4244
esac; \
43-
url="https://static.rust-lang.org/rustup/archive/1.25.1/${rustArch}/rustup-init"; \
45+
url="https://static.rust-lang.org/rustup/archive/1.26.0/${rustArch}/rustup-init"; \
4446
wget "$url"; \
4547
echo "${rustupSha256} *rustup-init" | sha256sum -c -; \
4648
chmod +x rustup-init; \

documentation/en/api-v1-methods.md

+11-3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
* [OnlineBackup](#onlinebackup)
5656
* [Pd](#pd)
5757
* [PdBuildIndexForPieceCid](#pdbuildindexforpiececid)
58+
* [PdCleanup](#pdcleanup)
5859
* [PdRemoveDealForPiece](#pdremovedealforpiece)
5960
##
6061

@@ -554,9 +555,7 @@ Perms: admin
554555
Inputs:
555556
```json
556557
[
557-
{
558-
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
559-
}
558+
"Ynl0ZSBhcnJheQ=="
560559
]
561560
```
562561

@@ -1245,6 +1244,15 @@ Inputs:
12451244

12461245
Response: `{}`
12471246

1247+
### PdCleanup
1248+
1249+
1250+
Perms: admin
1251+
1252+
Inputs: `null`
1253+
1254+
Response: `{}`
1255+
12481256
### PdRemoveDealForPiece
12491257

12501258

itests/ddo_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func TestDirectDeal(t *testing.T) {
5959
require.NoError(t, err)
6060
defer f.Stop()
6161

62-
// Send funs to PSD wallet as it is being used for POST
62+
// Send funds to PSD wallet as it is being used for POST
6363
info, err := f.FullNode.StateMinerInfo(ctx, f.MinerAddr, types.EmptyTSK)
6464
require.NoError(t, err)
6565
addresses := []address.Address{info.Owner, info.Worker}

0 commit comments

Comments
 (0)