Skip to content

Commit a144b95

Browse files
authored
feat: market 2.0 (#508)
* initial draft of market 2.0 * PUT endpoint for deals * add some type validation tests * info page and pdp router changes * client, commv2, ui * mk20 GC * aggregate deals * offline deal and put deals * finish UI * UI, reindex, retrievals * update pdp client service url * basic docs, new api, UI changes * chunk upload * fix actor info page * add some PDP metrics * use piecepark for upload * pcid2, pdpv1, retrievalv1 * PDP pipeline * openAPI, auth, streamline types and methods * pdp prove test * deleteRoot, deleteProofSet * serial upload * working PDP pipeline, indexing, ipni * rename PDP * lotus version * CommPV2 integration with PDP contracts * piece cleanup, string client * IPDPProvingSchedule changes * fix swagger definitions * switch to camelCase for json * undo m20 ddo download * undo camelCase * fix test * fix status, add status command * fix swagger types, UI fixes * fix pdp_ipni, ipni_ui * leftover PDP rename * fix swagger, ppinit * refactor cleanup, fix proving * fix tests * fix savecache and proving * make gen * fix cleanup, drop pdp cache * FS registry * fix translation and make gen
1 parent 446c600 commit a144b95

File tree

173 files changed

+38875
-3804
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

173 files changed

+38875
-3804
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ jobs:
179179
target: "./itests/harmonydb_test.go"
180180
- name: test-itest-alertnow
181181
target: "./itests/alertnow_test.go"
182+
- name: test-itest-pdp-prove
183+
target: "./itests/pdp_prove_test.go"
182184
steps:
183185
- uses: actions/checkout@v4
184186

@@ -311,6 +313,10 @@ jobs:
311313
run: go install github.com/hannahhoward/cbor-gen-for
312314
shell: bash
313315

316+
- name: Install swag cli
317+
run: go install github.com/swaggo/swag/cmd/[email protected]
318+
shell: bash
319+
314320
# - name: Install gotext
315321
# run: go install golang.org/x/text/cmd/gotext
316322
# shell: bash

Dockerfile

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ ENV RUSTUP_HOME=/usr/local/rustup \
1414
PATH=/usr/local/cargo/bin:$PATH \
1515
RUST_VERSION=1.63.0
1616

17+
COPY ./ /opt/curio
18+
WORKDIR /opt/curio
19+
RUN git submodule update --init
20+
RUN go mod download
21+
1722
RUN set -eux; \
1823
dpkgArch="$(dpkg --print-architecture)"; \
1924
case "${dpkgArch##*-}" in \
@@ -32,9 +37,6 @@ RUN set -eux; \
3237
cargo --version; \
3338
rustc --version;
3439

35-
COPY ./ /opt/curio
36-
WORKDIR /opt/curio
37-
3840
### make configurable filecoin-ffi build
3941
ARG FFI_BUILD_FROM_SOURCE=0
4042
ENV FFI_BUILD_FROM_SOURCE=${FFI_BUILD_FROM_SOURCE}
@@ -56,13 +58,26 @@ RUN go install github.com/ipld/go-car/cmd/car@latest \
5658
RUN go install github.com/LexLuthr/piece-server@latest \
5759
&& cp $GOPATH/bin/piece-server /usr/local/bin/
5860

59-
RUN go install github.com/ipni/storetheindex@v0.8.38 \
61+
RUN go install github.com/ipni/storetheindex@latest \
6062
&& cp $GOPATH/bin/storetheindex /usr/local/bin/
6163

64+
RUN go install github.com/ethereum/go-ethereum/cmd/geth@latest \
65+
&& cp $GOPATH/bin/geth /usr/local/bin/
66+
6267
#####################################
6368
FROM ubuntu:22.04 AS curio-all-in-one
6469

65-
RUN apt-get update && apt-get install -y dnsutils vim curl aria2 jq
70+
RUN apt-get update && apt-get install -y dnsutils vim curl aria2 jq git wget nodejs npm
71+
72+
# Install Foundry
73+
RUN curl -L https://foundry.paradigm.xyz | bash \
74+
&& bash -c ". ~/.foundry/bin/foundryup"
75+
76+
# Make sure foundry binaries are available in PATH
77+
ENV PATH="/root/.foundry/bin:${PATH}"
78+
79+
# Verify installation
80+
RUN forge --version && cast --version && anvil --version
6681

6782
# Copy libraries and binaries from curio-builder
6883
COPY --from=curio-builder /etc/ssl/certs /etc/ssl/certs
@@ -98,6 +113,7 @@ COPY --from=curio-builder /opt/curio/sptool /usr/local/bin/
98113
COPY --from=piece-server-builder /usr/local/bin/piece-server /usr/local/bin/
99114
COPY --from=piece-server-builder /usr/local/bin/car /usr/local/bin/
100115
COPY --from=piece-server-builder /usr/local/bin/storetheindex /usr/local/bin/
116+
COPY --from=piece-server-builder /usr/local/bin/geth /usr/local/bin/
101117

102118
# Set up directories and permissions
103119
RUN mkdir /var/tmp/filecoin-proof-parameters \

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,11 @@ go-generate:
266266
gen: gensimple
267267
.PHONY: gen
268268

269-
gensimple: api-gen go-generate cfgdoc-gen docsgen docsgen-cli
269+
marketgen:
270+
swag init -dir market/mk20/http -g http.go -o market/mk20/http --parseDependencyLevel 3 --parseDependency
271+
.PHONY: marketgen
272+
273+
gensimple: api-gen go-generate cfgdoc-gen docsgen marketgen docsgen-cli
270274
$(GOCC) run ./scripts/fiximports
271275
go mod tidy
272276
.PHONY: gen

alertmanager/alerts.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package alertmanager
33
import (
44
"bytes"
55
"context"
6-
"database/sql"
76
"fmt"
87
"math"
98
"strings"
@@ -13,6 +12,7 @@ import (
1312
"github.com/dustin/go-humanize"
1413
cbor "github.com/ipfs/go-ipld-cbor"
1514
"github.com/samber/lo"
15+
"github.com/yugabyte/pgx/v5"
1616
"golang.org/x/xerrors"
1717

1818
"github.com/filecoin-project/go-address"
@@ -346,7 +346,7 @@ func (al *alerts) getAddresses() ([]address.Address, []address.Address, error) {
346346
cfg := config.DefaultCurioConfig()
347347
err := al.db.QueryRow(al.ctx, `SELECT config FROM harmony_config WHERE title=$1`, layer).Scan(&text)
348348
if err != nil {
349-
if strings.Contains(err.Error(), sql.ErrNoRows.Error()) {
349+
if strings.Contains(err.Error(), pgx.ErrNoRows.Error()) {
350350
return nil, nil, xerrors.Errorf("missing layer '%s' ", layer)
351351
}
352352
return nil, nil, xerrors.Errorf("could not read layer '%s': %w", layer, err)
@@ -731,7 +731,7 @@ func missingSectorCheck(al *alerts) {
731731
SectorID int64 `db:"sector_num"`
732732
}
733733

734-
err := al.db.Select(al.ctx, &sectors, `SELECT miner_id, sector_num FROM sector_location WHERE sector_filetype = 2 GROUP BY miner_id, sector_num ORDER BY miner_id, sector_num`)
734+
err := al.db.Select(al.ctx, &sectors, `SELECT miner_id, sector_num FROM sector_location WHERE sector_filetype = ANY(ARRAY[2,8]) GROUP BY miner_id, sector_num ORDER BY miner_id, sector_num`)
735735
if err != nil {
736736
al.alertMap[Name].err = xerrors.Errorf("getting sealed sectors from database: %w", err)
737737
return

alertmanager/plugin/slack_webhook.go

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,29 +65,60 @@ func (s *SlackWebhook) SendAlert(data *AlertPayload) error {
6565

6666
// Iterate through the map to construct the remaining blocks
6767
for key, value := range data.Details {
68-
// Split value into sentences by period followed by space
68+
// Split value into sentences by period followed by space.
6969
sentences := strings.Split(value.(string), ". ")
70-
formattedValue := fmt.Sprintf("• *%s*\n", key)
7170

72-
// Add a bullet point before each trimmed sentence
71+
// Add the key as the header for each block.
72+
baseFormattedValue := fmt.Sprintf("• *%s*\n", key)
73+
currentFormattedValue := baseFormattedValue
74+
75+
// Keep track of the character limit (3000) when adding sentences.
7376
for _, sentence := range sentences {
74-
trimmedSentence := strings.TrimSpace(sentence) // Trim leading and trailing spaces
77+
trimmedSentence := strings.TrimSpace(sentence) // Trim leading and trailing spaces.
7578
if trimmedSentence != "" {
76-
formattedValue += fmt.Sprintf("• %s.\n", trimmedSentence) // Add period back and newline
79+
// Add a bullet point and sentence, restoring the period and newline.
80+
newSection := fmt.Sprintf("• %s.\n", trimmedSentence)
81+
82+
// Check if adding this section exceeds the 3000-character limit.
83+
if len(currentFormattedValue)+len(newSection) > 3000 {
84+
// If limit exceeds, add the currentFormattedValue block to payload and start a new block.
85+
payload.Blocks = append(payload.Blocks,
86+
Block{
87+
Type: "section",
88+
Text: &TextBlock{
89+
Type: "mrkdwn",
90+
Text: currentFormattedValue,
91+
},
92+
},
93+
Block{
94+
Type: "divider",
95+
},
96+
)
97+
98+
// Start a new formatted value with the baseFormattedValue.
99+
currentFormattedValue = baseFormattedValue
100+
}
101+
102+
// Append the newSection to the currentFormattedValue.
103+
currentFormattedValue += newSection
77104
}
78105
}
79-
payload.Blocks = append(payload.Blocks,
80-
Block{
81-
Type: "section",
82-
Text: &TextBlock{
83-
Type: "mrkdwn",
84-
Text: formattedValue,
106+
107+
// Add the last block if it contains any content.
108+
if currentFormattedValue != baseFormattedValue {
109+
payload.Blocks = append(payload.Blocks,
110+
Block{
111+
Type: "section",
112+
Text: &TextBlock{
113+
Type: "mrkdwn",
114+
Text: currentFormattedValue,
115+
},
85116
},
86-
},
87-
Block{
88-
Type: "divider",
89-
},
90-
)
117+
Block{
118+
Type: "divider",
119+
},
120+
)
121+
}
91122
}
92123

93124
// Marshal the payload to JSON
@@ -163,7 +194,8 @@ func (s *SlackWebhook) SendAlert(data *AlertPayload) error {
163194
}
164195
})
165196
if err != nil {
166-
return fmt.Errorf("after %d retries,last error: %w", iter, err)
197+
log.Errorw("Slack Webhook payload:", string(jsonData))
198+
return fmt.Errorf("after %d retries,last error: %w, %s", iter, err, string(jsonData))
167199
}
168200
return nil
169201
}

cmd/curio/debug-ipni.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ var testDebugIpniChunks = &cli.Command{
4848
return xerrors.Errorf("reading block: %w", err)
4949
}
5050

51-
_, err = ck.Finish(c.Context, nil, cid.Undef)
51+
_, err = ck.Finish(c.Context, nil, cid.Undef, false)
5252
if err != nil {
5353
return xerrors.Errorf("chunking CAR multihash iterator: %w", err)
5454
}

0 commit comments

Comments
 (0)