Skip to content
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1f41cd9
fix: validateIpniAdvertisement checks provider
SgtPooki Nov 11, 2025
1e6e823
Update src/core/utils/validate-ipni-advertisement.ts
SgtPooki Nov 12, 2025
afb18ae
Update src/core/utils/validate-ipni-advertisement.ts
SgtPooki Nov 12, 2025
7df9efd
fix: fine-tune logic, remove dead branches
SgtPooki Nov 12, 2025
20364d6
fix: allow ipniIndexer override, default to filecoinpin.contact
SgtPooki Nov 12, 2025
b62441f
fix: use only current provider serviceURL
SgtPooki Nov 12, 2025
1f95e4d
Update src/core/utils/validate-ipni-advertisement.ts
SgtPooki Nov 12, 2025
4c0c1c2
Update src/core/utils/validate-ipni-advertisement.ts
SgtPooki Nov 12, 2025
fa10f75
Update src/core/utils/validate-ipni-advertisement.ts
SgtPooki Nov 12, 2025
ad90c71
Update src/core/utils/validate-ipni-advertisement.ts
SgtPooki Nov 12, 2025
31c6097
chore: more logic cleanup
SgtPooki Nov 12, 2025
915e7e9
fix: display received + expected multiaddrs
SgtPooki Nov 12, 2025
a2df72f
refactor: inline simple maps and filters
SgtPooki Nov 12, 2025
0484671
chore: more code cleanup
SgtPooki Nov 12, 2025
35e989b
fix: PDP definition
SgtPooki Nov 12, 2025
e5ea86d
chore: cleanup validateIpni options set in executeUpload
SgtPooki Nov 12, 2025
540da6e
fix: last error message
SgtPooki Nov 12, 2025
a89a445
Update src/core/utils/validate-ipni-advertisement.ts
SgtPooki Nov 12, 2025
1ff3746
Update src/core/utils/validate-ipni-advertisement.ts
SgtPooki Nov 12, 2025
c0302d3
Update src/test/unit/validate-ipni-advertisement.test.ts
SgtPooki Nov 12, 2025
d092307
Update src/test/unit/validate-ipni-advertisement.test.ts
SgtPooki Nov 12, 2025
ea21fc7
Update src/test/unit/validate-ipni-advertisement.test.ts
SgtPooki Nov 12, 2025
8d5d654
Update src/test/unit/validate-ipni-advertisement.test.ts
SgtPooki Nov 12, 2025
6a55fef
Update src/core/utils/validate-ipni-advertisement.ts
SgtPooki Nov 12, 2025
623bf87
Update src/core/utils/validate-ipni-advertisement.ts
SgtPooki Nov 12, 2025
23cab56
fix: remove expectedProviderMultiaddrs
SgtPooki Nov 12, 2025
7bd2632
refactor: validateIPNIadvertisement -> waitForIpniProviderResults
SgtPooki Nov 12, 2025
6ea2930
fix: use set operations, finish move to waitForIpniProviderResults
SgtPooki Nov 12, 2025
33f1ae9
fix: update terminology, ipniAdvertisement -> ipni provider results
SgtPooki Nov 12, 2025
c1edc16
fix: include Set operations in typescript
SgtPooki Nov 13, 2025
3ae6b18
Update src/core/utils/validate-ipni-advertisement.ts
SgtPooki Nov 13, 2025
83177bc
Update src/core/utils/validate-ipni-advertisement.ts
SgtPooki Nov 13, 2025
edb047a
Update src/core/utils/validate-ipni-advertisement.ts
SgtPooki Nov 13, 2025
bcc6b8a
chore: lint fix
SgtPooki Nov 13, 2025
6f595e1
test: fix tests after error msg change
SgtPooki Nov 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/common/upload-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export async function performUpload(

let pieceCid: PieceCID | undefined
function getIpniAdvertisementMsg(attemptCount: number): string {
return `Checking for IPNI advertisement (check #${attemptCount})`
return `Checking for IPNI provider records (check #${attemptCount})`
}

const uploadResult = await executeUpload(synapseService, carData, rootCid, {
Expand Down Expand Up @@ -321,14 +321,14 @@ export async function performUpload(
break
}

case 'ipniAdvertisement.retryUpdate': {
case 'ipniProviderResults.retryUpdate': {
const attemptCount = event.data.retryCount === 0 ? 1 : event.data.retryCount + 1
flow.addOperation('ipni', getIpniAdvertisementMsg(attemptCount))
break
}
case 'ipniAdvertisement.complete': {
case 'ipniProviderResults.complete': {
// complete event is only emitted when result === true (success)
flow.completeOperation('ipni', 'IPNI advertisement successful. IPFS retrieval possible.', {
flow.completeOperation('ipni', 'IPNI provider records found. IPFS retrieval possible.', {
type: 'success',
details: {
title: 'IPFS Retrieval URLs',
Expand All @@ -341,12 +341,12 @@ export async function performUpload(
})
break
}
case 'ipniAdvertisement.failed': {
flow.completeOperation('ipni', 'IPNI advertisement failed.', {
case 'ipniProviderResults.failed': {
flow.completeOperation('ipni', 'IPNI provider records not found.', {
type: 'warning',
details: {
title: 'IPFS retrieval is not possible yet.',
content: [pc.gray(`IPNI advertisement does not exist at http://filecoinpin.contact/cid/${rootCid}`)],
content: [pc.gray(`IPNI provider records for this SP does not exist for the provided root CID`)],
},
})
break
Expand Down
38 changes: 28 additions & 10 deletions src/core/upload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import {
import { isSessionKeyMode, type SynapseService } from '../synapse/index.js'
import type { ProgressEvent, ProgressEventHandler } from '../utils/types.js'
import {
type ValidateIPNIAdvertisementOptions,
type ValidateIPNIProgressEvents,
validateIPNIAdvertisement,
type WaitForIpniProviderResultsOptions,
waitForIpniProviderResults,
} from '../utils/validate-ipni-advertisement.js'
import { type SynapseUploadResult, type UploadProgressEvents, uploadToSynapse } from './synapse.js'

Expand Down Expand Up @@ -195,7 +195,7 @@ export interface UploadExecutionOptions {
* @default: true
*/
enabled?: boolean
} & Omit<ValidateIPNIAdvertisementOptions, 'onProgress'>
} & Omit<WaitForIpniProviderResultsOptions, 'onProgress'>
}

export interface UploadExecutionResult extends SynapseUploadResult {
Expand Down Expand Up @@ -230,13 +230,31 @@ export async function executeUpload(
case 'onPieceAdded': {
// Begin IPNI validation as soon as the piece is added and parked in the data set
if (options.ipniValidation?.enabled !== false && ipniValidationPromise == null) {
const { enabled: _enabled, ...rest } = options.ipniValidation ?? {}
ipniValidationPromise = validateIPNIAdvertisement(rootCid, {
...rest,
const { enabled: _enabled, expectedProviders, ...restOptions } = options.ipniValidation ?? {}

// Build validation options
const validationOptions: WaitForIpniProviderResultsOptions = {
...restOptions,
logger,
...(options?.onProgress != null ? { onProgress: options.onProgress } : {}),
}).catch((error) => {
logger.warn({ error }, 'IPNI advertisement validation promise rejected')
}

// Forward progress events to caller if they provided a handler
if (options?.onProgress != null) {
validationOptions.onProgress = options.onProgress
}

// Determine which providers to expect in IPNI
// Priority: user-provided expectedProviders > current provider > none (generic validation)
// Note: If expectedProviders is explicitly [], we respect that (no provider expectations)
if (expectedProviders != null) {
validationOptions.expectedProviders = expectedProviders
} else if (synapseService.providerInfo != null) {
validationOptions.expectedProviders = [synapseService.providerInfo]
}
Comment on lines +248 to +253
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BigLep most folks will call through this method, which will set expectedProviders to the correct thing (and to the multi-providers for multi-provider uploads once synapse-sdk is updated)


// Start validation (runs in parallel with other operations)
ipniValidationPromise = waitForIpniProviderResults(rootCid, validationOptions).catch((error) => {
logger.warn({ error }, 'IPNI provider results check was rejected')
return false
})
}
Expand Down Expand Up @@ -270,7 +288,7 @@ export async function executeUpload(
try {
ipniValidated = await ipniValidationPromise
} catch (error) {
logger.error({ error }, 'Could not validate IPNI advertisement')
logger.error({ error }, 'Could not validate IPNI provider records')
ipniValidated = false
}
}
Expand Down
Loading
Loading