Skip to content
Merged
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ jobs:
if: ${{ failure() }}
run: |
echo "========== Ocean Node Logs =========="
tac ${{ github.workspace }}/ocean-node/start-node.log || echo "Log file not found"
tac ${{ github.workspace }}/barge/start-node.log || echo "Log file not found"
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
Expand Down
8 changes: 7 additions & 1 deletion ComputeExamples.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,13 @@ const DATASET_DDO: DDO = {
timeout: 300,
compute: {
publisherTrustedAlgorithmPublishers: ['*'] as any,
publisherTrustedAlgorithms: ['*'] as any,
publisherTrustedAlgorithms: [
{
did: '*',
filesChecksum: '*',
containerSectionChecksum: '*'
}
] as any,
allowRawAlgorithm: false,
allowNetworkAccess: true
}
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"dependencies": {
"@oasisprotocol/sapphire-paratime": "^1.3.2",
"@oceanprotocol/contracts": "^2.3.0",
"@oceanprotocol/ddo-js": "^0.1.0",
"@oceanprotocol/ddo-js": "^0.1.2",
"@rdfjs/dataset": "^2.0.2",
"@rdfjs/formats-common": "^3.1.0",
"@zazuko/env-node": "^2.1.4",
Expand Down
7 changes: 7 additions & 0 deletions src/@types/PolicyServer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export interface PolicyServer {
sessionId?: string
successRedirectUri?: string
errorRedirectUri?: string
responseRedirectUri?: string
presentationDefinitionUri?: string
}
17 changes: 14 additions & 3 deletions src/services/Provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
ComputeJobMetadata
} from '../@types'
import { decodeJwt } from '../utils/Jwt.js'
import { PolicyServer } from '../@types/PolicyServer.js'

export class Provider {
private async getConsumerAddress(signerOrAuthToken: Signer | string): Promise<string> {
Expand Down Expand Up @@ -512,6 +513,7 @@ export class Provider {
* @param {SignerOrAuthToken} signerOrAuthToken Signer or auth token
* @param {ComputeResourceRequest[]} resources The resources to start compute job with.
* @param {number} chainId The chain used to do payments
* @param {PolicyServer} policyServer The policy server object.
* @param {AbortSignal} signal abort signal
* @return {Promise<ProviderComputeInitialize>} ProviderComputeInitialize data
*/
Expand All @@ -525,6 +527,7 @@ export class Provider {
signerOrAuthToken: Signer | string,
resources: ComputeResourceRequest[],
chainId: number,
policyServer?: PolicyServer,
signal?: AbortSignal
): Promise<ProviderComputeInitializeResults> {
const providerEndpoints = await this.getEndpoints(providerUri)
Expand Down Expand Up @@ -556,7 +559,7 @@ export class Provider {
signatureMessage += nonce
const signature = await this.getSignature(signerOrAuthToken, signatureMessage)

const providerData: Object = {
const providerData: Record<string, any> = {
datasets: assets,
algorithm,
environment: computeEnv,
Expand All @@ -570,6 +573,8 @@ export class Provider {
signature
}

if (policyServer) providerData.policyServer = policyServer

let response
try {
console.log('Initialize compute url:', initializeUrl)
Expand Down Expand Up @@ -615,7 +620,7 @@ export class Provider {
* @param {string} transferTxId - The transfer transaction ID.
* @param {string} providerUri - The provider URI.
* @param {SignerOrAuthToken} signerOrAuthToken - The signer or auth token.
* @param {any} policyServer - The policy server (if any is to be used).
* @param {PolicyServer} policyServer - The policy server (if any is to be used).
* @param {UserCustomParameters} userCustomParameters - The user custom parameters.
* @returns {Promise<any>} The download URL.
*/
Expand All @@ -626,7 +631,7 @@ export class Provider {
transferTxId: string,
providerUri: string,
signerOrAuthToken: Signer | string,
policyServer?: any,
policyServer?: PolicyServer,
userCustomParameters?: UserCustomParameters
): Promise<any> {
const providerEndpoints = await this.getEndpoints(providerUri)
Expand Down Expand Up @@ -763,6 +768,7 @@ export class Provider {
* @param {chainId} chainId The chain used to do payments
* @param {ComputeJobMetadata} metadata The compute job metadata. Additional metadata to be stored in the database.
* @param {ComputeOutput} output The compute job output settings.
* @param {PolicyServer} policyServer The policy server object.
* @param {AbortSignal} signal abort signal
* @return {Promise<ComputeJob | ComputeJob[]>} The compute job or jobs.
*/
Expand All @@ -778,6 +784,7 @@ export class Provider {
chainId: number, // network used by payment (only for payed compute jobs)
metadata?: ComputeJobMetadata,
output?: ComputeOutput,
policyServer?: PolicyServer,
signal?: AbortSignal
): Promise<ComputeJob | ComputeJob[]> {
console.log('called new compute start method...')
Expand Down Expand Up @@ -837,6 +844,7 @@ export class Provider {
if (metadata) payload.metadata = metadata
// if (additionalDatasets) payload.additionalDatasets = additionalDatasets
if (output) payload.output = output
if (policyServer) payload.policyServer = policyServer
let response
try {
response = await fetch(computeStartUrl, {
Expand Down Expand Up @@ -877,6 +885,7 @@ export class Provider {
* @param {ComputeResourceRequest} resources The resources to start compute job with.
* @param {ComputeJobMetadata} metadata The compute job metadata. Additional metadata to be stored in the database.
* @param {ComputeOutput} output The compute job output settings.
* @param {PolicyServer} policyServer The policy server object.
* @param {AbortSignal} signal abort signal
* @return {Promise<ComputeJob | ComputeJob[]>} The compute job or jobs.
*/
Expand All @@ -889,6 +898,7 @@ export class Provider {
resources?: ComputeResourceRequest[],
metadata?: ComputeJobMetadata,
output?: ComputeOutput,
policyServer?: PolicyServer,
signal?: AbortSignal
): Promise<ComputeJob | ComputeJob[]> {
console.log('called new free compute start method...')
Expand Down Expand Up @@ -939,6 +949,7 @@ export class Provider {
if (metadata) payload.metadata = metadata
// if (additionalDatasets) payload.additionalDatasets = additionalDatasets
payload.output = output
if (policyServer) payload.policyServer = policyServer
let response
try {
response = await fetch(computeStartUrl, {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/ComputeExamples.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ const DATASET_DDO: DDO = {
filesChecksum: '*',
containerSectionChecksum: '*'
}
],
] as any,
allowRawAlgorithm: false,
allowNetworkAccess: true
}
Expand Down
7 changes: 4 additions & 3 deletions test/integration/ComputeFlow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ let escrow: EscrowContract
let freeComputeRouteSupport = null

const computeJobDuration = 60 * 15 // 15 minutes
let computeMinutes: number

const assetUrl: Files = {
datatokenAddress: '0x0',
Expand Down Expand Up @@ -495,7 +496,7 @@ describe('Compute flow tests', async () => {

it('Should fast forward time and set a new computeValidUntil', async () => {
const mytime = new Date()
const computeMinutes = 2
computeMinutes = 2
mytime.setMinutes(mytime.getMinutes() + computeMinutes)
computeValidUntil = Math.floor(mytime.getTime() / 1000)
})
Expand Down Expand Up @@ -613,8 +614,8 @@ describe('Compute flow tests', async () => {
assert(
Number(
ethers.utils.formatUnits(providerInitializeComputeResults.payment.amount, 18)
) >=
(computeEnv.maxJobDuration / 60) * price,
) ===
(computeEnv.maxJobDuration / 60) * price * computeMinutes,
'Incorrect payment token amount'
) // 60 minutes per price 1 -> amount = 60
assert(
Expand Down
Loading