Skip to content

Commit 4bb5343

Browse files
committed
fixup! feat: add devnet network support and --skip-ipni flag
1 parent 1d15965 commit 4bb5343

File tree

8 files changed

+51
-25
lines changed

8 files changed

+51
-25
lines changed

AGENTS.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Bridges IPFS content to Filecoin storage providers with cryptographic guarantees
1010

1111
**Stack**: filecoin-pin → synapse-sdk → FOC contracts (FWSS, FilecoinPay, PDPVerifier, SPRegistry) + Curio.
1212

13-
**Status**: Calibration testnet only. Not production-ready.
13+
**Status**: Supports Mainnet, Calibration testnet, and local devnet (foc-devnet). CLI defaults to Calibration.
1414

1515
## Design Philosophy
1616

@@ -25,10 +25,12 @@ Bridges IPFS content to Filecoin storage providers with cryptographic guarantees
2525
```
2626
src/
2727
├── cli.ts, server.ts # Commander.js CLI + Fastify server
28-
├── add/, data-set/ # Command implementations
28+
├── add/, import/, data-set/ # Command implementations
2929
├── core/ # Published library (see package.json exports)
3030
│ ├── car/ # CAR file handling (CARv1 streaming)
3131
│ ├── payments/ # Payment setup/status
32+
│ ├── metadata/ # Metadata normalization
33+
│ ├── piece/ # Piece status queries
3234
│ ├── synapse/ # SDK initialization patterns
3335
│ ├── upload/ # Upload workflows
3436
│ ├── unixfs/ # Helia integration, browser/node variants
@@ -50,13 +52,13 @@ src/
5052

5153
## Key Patterns
5254

53-
**Synapse SDK**: Initialize with callbacks (onProviderSelected, onDataSetResolved, onPieceAdded), upload returns {pieceCid, pieceId, provider}. See `src/core/synapse/index.ts`, `src/core/upload/synapse.ts`.
55+
**Synapse SDK**: Initialize via `initializeSynapse()` in `src/core/synapse/index.ts`. Upload via `executeUpload()` in `src/core/upload/index.ts` with progress events (`onStored`, `onPullProgress`, `onCopyComplete`, `onPiecesAdded`, `onPiecesConfirmed`). Returns `{pieceCid, size, copies, failures}`.
5456

5557
**CAR files**: CARv1 streaming, handle 3 root cases (single/multiple/none), use zero CID for no roots. See `src/core/car/car-blockstore.ts`.
5658

5759
**UnixFS**: Helia for directory imports, chunking, CID calculation. See `src/core/unixfs/`.
5860

59-
**Payments**: `checkPaymentStatus()`, `setupPayments()` in `src/core/payments/index.ts`.
61+
**Payments**: `getPaymentStatus()`, `setMaxAllowances()`, `validatePaymentCapacity()` in `src/core/payments/index.ts`.
6062

6163
## Biome Linting (Critical)
6264

@@ -84,11 +86,13 @@ src/
8486

8587
## CLI & Environment
8688

87-
**Commands**: `payments setup --auto`, `add <file>`, `payments status`, `data-set <id>`, `server`
89+
**Commands**: `payments setup --auto`, `add <path>`, `import <car-file>`, `payments status`, `data-set <id>`, `server`
8890

89-
**Required env**: `PRIVATE_KEY=0x...` (with USDFC tokens)
91+
**Network**: `--network mainnet|calibration|devnet` (default: `calibration`). Devnet reads config from foc-devnet's `devnet-info.json` and auto-resolves private key and RPC URL.
9092

91-
**Optional**: `RPC_URL` (default: Calibration), `PORT`, `HOST`, `DATABASE_PATH`, `CAR_STORAGE_PATH`, `LOG_LEVEL`
93+
**Required env**: `PRIVATE_KEY=0x...` (with USDFC tokens; not needed for devnet)
94+
95+
**Optional**: `NETWORK`, `RPC_URL`, `FOC_DEVNET_BASEDIR`, `DEVNET_INFO_PATH`, `DEVNET_USER_INDEX`, `PORT`, `HOST`, `DATABASE_PATH`, `CAR_STORAGE_PATH`, `LOG_LEVEL`
9296

9397
**Default data dirs for pinning server**: Linux `~/.local/share/filecoin-pin/`, macOS `~/Library/Application Support/filecoin-pin/`, Windows `%APPDATA%/filecoin-pin/`
9498

README.md

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ The Pinning Server requires the use of environment variables, as detailed below.
165165

166166
### Network Selection
167167

168-
Filecoin Pin supports both **Mainnet** and **Calibration testnet**. By default, the CLI uses Calibration testnet during development.
168+
Filecoin Pin supports **Mainnet**, **Calibration testnet**, and local **devnet** networks. By default, the CLI uses Calibration testnet.
169169

170170
**Using the CLI:**
171171
```bash
@@ -177,6 +177,9 @@ filecoin-pin add myfile.txt --network mainnet
177177

178178
# Explicitly specify Calibration
179179
filecoin-pin add myfile.txt --network calibration
180+
181+
# Use a local foc-devnet (reads config from devnet-info.json, details below)
182+
filecoin-pin add myfile.txt --network devnet
180183
```
181184

182185
**Using environment variables:**
@@ -196,13 +199,30 @@ filecoin-pin add myfile.txt
196199
3. `--network` flag or `NETWORK` environment variable
197200
4. Default to Calibration testnet
198201

202+
### Local Development with foc-devnet
203+
204+
When using `--network devnet`, Filecoin Pin reads connection details from a running [foc-devnet](https://github.com/filecoin-project/foc-devnet) instance:
205+
206+
- **Private key**: Automatically resolved from `devnet-info.json` (no `PRIVATE_KEY` needed)
207+
- **RPC URL**: Read from the devnet chain configuration
208+
- **Contract addresses**: Resolved from the devnet chain definition
209+
- **IPNI verification**: Automatically skipped (no IPNI infrastructure on devnet)
210+
211+
**Environment variables for devnet:**
212+
213+
| Variable | Description | Default |
214+
|----------|-------------|---------|
215+
| `FOC_DEVNET_BASEDIR` | Override the foc-devnet base directory | `~/.foc-devnet` |
216+
| `DEVNET_INFO_PATH` | Explicit path to `devnet-info.json` (overrides basedir) | `<basedir>/state/latest/devnet-info.json` |
217+
| `DEVNET_USER_INDEX` | Which user from `devnet-info.json` to use | `0` |
218+
199219
### Common CLI Arguments
200220

201221
* `-h`, `--help`: Display help information for each command
202222
* `-V`, `--version`: Output the version number
203223
* `-v`, `--verbose`: Verbose output
204224
* `--private-key`: Ethereum-style (`0x`) private key, funded with USDFC (required)
205-
* `--network`: Filecoin network to use: `mainnet` or `calibration` (default: `calibration`)
225+
* `--network`: Filecoin network to use: `mainnet`, `calibration`, or `devnet` (default: `calibration`)
206226
* `--rpc-url`: Filecoin RPC endpoint (overrides `--network` if specified)
207227

208228
Other arguments are possible for individual commands, use `--help` to find out more.
@@ -214,10 +234,10 @@ Other arguments are possible for individual commands, use `--help` to find out m
214234
PRIVATE_KEY=0x... # Ethereum private key with USDFC tokens
215235

216236
# Optional - Network Configuration
217-
NETWORK=mainnet # Network to use: mainnet or calibration (default: calibration)
237+
NETWORK=mainnet # Network to use: mainnet, calibration, or devnet (default: calibration)
218238
RPC_URL=wss://... # Filecoin RPC endpoint (overrides NETWORK if specified)
219-
# Mainnet: wss://wss.node.glif.io/apigw/lotus/rpc/v1
220-
# Calibration: wss://wss.calibration.node.glif.io/apigw/lotus/rpc/v1
239+
# Mainnet: wss://wss.node.glif.io/apigw/lotus/rpc/v1
240+
# Calibration: wss://wss.calibration.node.glif.io/apigw/lotus/rpc/v1
221241

222242
# Optional for Pinning Server Daemon
223243
PORT=3456 # Daemon server port

src/add/add.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,14 @@ export async function runAdd(options: AddOptions): Promise<AddResult> {
168168
}
169169

170170
// Auto-skip IPNI on devnet (no IPNI infrastructure available)
171-
const skipIpni = options.skipIpni || synapse.chain.id === DEVNET_CHAIN_ID
171+
const skipIpniVerification = options.skipIpniVerification || synapse.chain.id === DEVNET_CHAIN_ID
172172

173173
const uploadOptions: Parameters<typeof performUpload>[3] = {
174174
contextType: 'add',
175175
fileSize: carSize,
176176
logger,
177177
spinner,
178-
skipIpni,
178+
skipIpniVerification,
179179
...(pieceMetadata && { pieceMetadata }),
180180
...(dataSetMetadata && { metadata: dataSetMetadata }),
181181
...(options.count != null && { count: options.count }),

src/add/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export interface AddOptions extends CLIAuthOptions {
1313
/** Data set metadata applied when creating or updating the storage context */
1414
dataSetMetadata?: Record<string, string>
1515
/** Skip IPNI advertisement verification after upload */
16-
skipIpni?: boolean
16+
skipIpniVerification?: boolean
1717
}
1818

1919
export interface AddResult {

src/common/upload-flow.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export interface UploadFlowOptions {
6161
metadata?: Record<string, string>
6262

6363
/** Skip IPNI advertisement verification after upload */
64-
skipIpni?: boolean
64+
skipIpniVerification?: boolean
6565
}
6666

6767
export interface UploadFlowResult extends SynapseUploadResult {
@@ -318,7 +318,7 @@ export async function performUpload(
318318
...(options.dataSetIds != null && { dataSetIds: options.dataSetIds }),
319319
...(options.excludeProviderIds != null && { excludeProviderIds: options.excludeProviderIds }),
320320
...(options.metadata != null && { metadata: options.metadata }),
321-
...(options.skipIpni && { ipniValidation: { enabled: false } }),
321+
...(options.skipIpniVerification && { ipniValidation: { enabled: false } }),
322322
onProgress(event) {
323323
switch (event.type) {
324324
case 'onStored': {

src/import/import.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,14 @@ export async function runCarImport(options: ImportOptions): Promise<ImportResult
214214
const carData = await readFile(options.filePath)
215215

216216
// Auto-skip IPNI on devnet (no IPNI infrastructure available)
217-
const skipIpni = options.skipIpni || synapse.chain.id === DEVNET_CHAIN_ID
217+
const skipIpniVerification = options.skipIpniVerification || synapse.chain.id === DEVNET_CHAIN_ID
218218

219219
const uploadOptions: Parameters<typeof performUpload>[3] = {
220220
contextType: 'import',
221221
fileSize: fileStat.size,
222222
logger,
223223
spinner,
224-
skipIpni,
224+
skipIpniVerification,
225225
...(pieceMetadata && { pieceMetadata }),
226226
...(dataSetMetadata && { metadata: dataSetMetadata }),
227227
...(options.count != null && { count: options.count }),

src/import/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export interface ImportOptions extends CLIAuthOptions {
1212
/** Data set metadata applied when creating or updating the storage context */
1313
dataSetMetadata?: Record<string, string>
1414
/** Skip IPNI advertisement verification after upload */
15-
skipIpni?: boolean
15+
skipIpniVerification?: boolean
1616
}
1717

1818
export interface ImportResult {

src/utils/cli-options.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ export function addNetworkOptions(command: Command): Command {
8585
new Option(
8686
'--network <network>',
8787
'Filecoin network to use. "devnet" reads config from foc-devnet ' +
88-
'(env: FOC_DEVNET_BASEDIR or DEVNET_INFO_PATH, DEVNET_USER_INDEX)'
88+
'(https://github.com/filecoin-project/foc-devnet, ' +
89+
'env: FOC_DEVNET_BASEDIR or DEVNET_INFO_PATH, DEVNET_USER_INDEX)'
8990
)
9091
.choices(['mainnet', 'calibration', 'devnet'])
9192
.env('NETWORK')
@@ -96,13 +97,14 @@ export function addNetworkOptions(command: Command): Command {
9697
}
9798

9899
/**
99-
* Add upload-specific options (skip-ipni) to a command.
100+
* Add upload-specific options to a command.
100101
* Used by `add` and `import` commands.
101102
*/
102103
export function addUploadOptions(command: Command): Command {
103104
return command.addOption(
104-
new Option('--skip-ipni', 'Skip IPNI advertisement verification after upload (automatic for devnet)').env(
105-
'SKIP_IPNI'
106-
)
105+
new Option(
106+
'--skip-ipni-verification',
107+
'Skip IPNI advertisement verification after upload (automatic for devnet)'
108+
).env('SKIP_IPNI_VERIFICATION')
107109
)
108110
}

0 commit comments

Comments
 (0)