Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: update compute status/stop to support agreementId, not documentId, sig fix #1822

Merged
merged 25 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9d58208
wip: update to support agreementId
paulo-ocean Jun 21, 2024
af9a8e7
Merge branch 'main' into issue-1820-fix-compute-status
paulo-ocean Jun 25, 2024
1dcafcf
wip: debug agreemenet id
paulo-ocean Jun 25, 2024
1242a68
Merge 1dcafcff6cd51b1d3f0ec4a7ce882ad727a2267b into a00211e8d8dbeeacc…
paulo-ocean Jun 25, 2024
7a6a057
Updating ComputeExamples.md
Jun 25, 2024
58fc815
update get status example, update test
paulo-ocean Jun 25, 2024
0abb448
merge conficts
paulo-ocean Jun 25, 2024
713780d
Merge 0abb44852f3724a9a93d9cf90f92a05f518c7bf7 into a00211e8d8dbeeacc…
paulo-ocean Jun 25, 2024
c6f826c
Updating ComputeExamples.md
Jun 25, 2024
7448a12
Merge branch 'main' into issue-1820-fix-compute-status
paulo-ocean Jun 25, 2024
5105a4f
update compute stop, document id is not needed, neither for operator …
paulo-ocean Jun 25, 2024
a30665f
bump version
paulo-ocean Jun 26, 2024
5f7d309
update computeStop, add some comments explaining the flow issues on t…
paulo-ocean Jun 26, 2024
dc675a3
revert version change
paulo-ocean Jun 27, 2024
6f13fe7
Release 3.3.3-next.0
paulo-ocean Jun 27, 2024
bb44f76
fix test
paulo-ocean Jun 28, 2024
974f3aa
debug: add more timeout to test
paulo-ocean Jun 28, 2024
fb50bee
try swap tests order , debug
paulo-ocean Jun 28, 2024
557289e
put timeout back and test order,mut be ipfs side temporary
paulo-ocean Jun 28, 2024
986f8fa
debug test
paulo-ocean Jul 1, 2024
50a515b
more debug
paulo-ocean Jul 1, 2024
0d09bd3
more debug
paulo-ocean Jul 1, 2024
c5b2fc5
more debugging
paulo-ocean Jul 1, 2024
88fea27
try other ipfs file
paulo-ocean Jul 1, 2024
4e0536a
remove console.logs
paulo-ocean Jul 1, 2024
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
47 changes: 27 additions & 20 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v3.3.3-next.0](https://github.com/oceanprotocol/ocean.js/compare/v3.3.2...v3.3.3-next.0)

- wip: update to support agreementId [`9d58208`](https://github.com/oceanprotocol/ocean.js/commit/9d582082f05cab961915aef04e74f8e32fd7ba9c)
- update compute stop, document id is not needed, neither for operator service, neither used on signature check [`5105a4f`](https://github.com/oceanprotocol/ocean.js/commit/5105a4fdadbf5590ebf2954a1d6f3a12f77b235c)
- wip: debug agreemenet id [`1dcafcf`](https://github.com/oceanprotocol/ocean.js/commit/1dcafcff6cd51b1d3f0ec4a7ce882ad727a2267b)

#### [v3.3.2](https://github.com/oceanprotocol/ocean.js/compare/v3.3.1...v3.3.2)

> 25 June 2024

- Split coupled tests to fix timeout issues [`#1827`](https://github.com/oceanprotocol/ocean.js/pull/1827)
- Bump braces from 3.0.2 to 3.0.3 [`#1819`](https://github.com/oceanprotocol/ocean.js/pull/1819)
- Bump chai-spies and @types/chai-spies [`#1816`](https://github.com/oceanprotocol/ocean.js/pull/1816)
- Pontus x devnet config [`#1806`](https://github.com/oceanprotocol/ocean.js/pull/1806)
- Update CODEOWNERS [`#1824`](https://github.com/oceanprotocol/ocean.js/pull/1824)
- Sanitize service endpoint by adding/reving slash when needed. [`#1821`](https://github.com/oceanprotocol/ocean.js/pull/1821)
- Release 3.3.2 [`3ba3ccb`](https://github.com/oceanprotocol/ocean.js/commit/3ba3ccb6b5df9caa87e31dfb316a1c1c74a6740c)

#### [v3.3.1](https://github.com/oceanprotocol/ocean.js/compare/v3.3.0...v3.3.1)

Expand Down Expand Up @@ -84,29 +93,15 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- make sure we increment a number when working with nonces [`#1781`](https://github.com/oceanprotocol/ocean.js/pull/1781)
- Release 3.1.4 [`b2e2cf2`](https://github.com/oceanprotocol/ocean.js/commit/b2e2cf24293af07f597c25e3a3e392db9caa381a)

#### [v3.1.3](https://github.com/oceanprotocol/ocean.js/compare/v3.1.3-next.1...v3.1.3)
#### [v3.1.3](https://github.com/oceanprotocol/ocean.js/compare/v3.1.2...v3.1.3)

> 16 October 2023

- fix fs use & error handling [`#1777`](https://github.com/oceanprotocol/ocean.js/pull/1777)
- Bump postcss from 8.4.5 to 8.4.31 [`#1778`](https://github.com/oceanprotocol/ocean.js/pull/1778)
- Release 3.1.3 [`1bc5a39`](https://github.com/oceanprotocol/ocean.js/commit/1bc5a39fda217c91cf5c44f41c6275acd20740de)

#### [v3.1.3-next.1](https://github.com/oceanprotocol/ocean.js/compare/v3.1.3-next.0...v3.1.3-next.1)

> 11 October 2023

- update error handling [`aada8e9`](https://github.com/oceanprotocol/ocean.js/commit/aada8e92af9273ccc20e86dc00ea73bcb7e8dfdf)
- Release 3.1.3-next.1 [`40c22b9`](https://github.com/oceanprotocol/ocean.js/commit/40c22b9b1fa147fd4295da1bdd6248d7714a2b30)

#### [v3.1.3-next.0](https://github.com/oceanprotocol/ocean.js/compare/v3.1.2...v3.1.3-next.0)

> 6 October 2023

- Bump @types/crypto-js from 4.1.1 to 4.1.2 [`#1774`](https://github.com/oceanprotocol/ocean.js/pull/1774)
- Bump @types/chai-spies from 1.0.3 to 1.0.4 [`#1776`](https://github.com/oceanprotocol/ocean.js/pull/1776)
- fix fs use [`735dc2f`](https://github.com/oceanprotocol/ocean.js/commit/735dc2f62b976be683bc9fcd7f8940e715b18519)
- Release 3.1.3-next.0 [`5ac5d1f`](https://github.com/oceanprotocol/ocean.js/commit/5ac5d1f44a637b5d8d285757941b0393bb3a7983)
- Release 3.1.3 [`1bc5a39`](https://github.com/oceanprotocol/ocean.js/commit/1bc5a39fda217c91cf5c44f41c6275acd20740de)

#### [v3.1.2](https://github.com/oceanprotocol/ocean.js/compare/v3.1.1...v3.1.2)

Expand Down Expand Up @@ -584,17 +579,29 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- Bump typedoc from 0.22.15 to 0.22.17 [`#1514`](https://github.com/oceanprotocol/ocean.js/pull/1514)
- Release 1.1.3 [`7772e93`](https://github.com/oceanprotocol/ocean.js/commit/7772e9387ef9d63f98ea80cfd4eefbea963dd0ad)

#### [v1.1.2](https://github.com/oceanprotocol/ocean.js/compare/v1.0.0...v1.1.2)
#### [v1.1.2](https://github.com/oceanprotocol/ocean.js/compare/v1.1.1...v1.1.2)

> 15 June 2022

- Release 1.1.2 [`85bf271`](https://github.com/oceanprotocol/ocean.js/commit/85bf2716e26d8691aeb9d5504e563d557419dc2e)
- manual bump fix [`5674a54`](https://github.com/oceanprotocol/ocean.js/commit/5674a547d1d367ce88b3595f0be8ebbf12274266)

#### [v1.1.1](https://github.com/oceanprotocol/ocean.js/compare/v1.1.0...v1.1.1)

> 15 June 2022

- Release 1.1.1 [`ea48e01`](https://github.com/oceanprotocol/ocean.js/commit/ea48e015ac8299f71d57a929f8f30c5d1a8446e7)
- manual bump fix [`a362410`](https://github.com/oceanprotocol/ocean.js/commit/a36241004b1d9578ec5c02d9d6e64d9750c53a7b)

#### [v1.1.0](https://github.com/oceanprotocol/ocean.js/compare/v1.0.0...v1.1.0)

> 15 June 2022

- Issue-#1485: Remove imports of ABIs in the tests and use utility tranfer(), mint(), balance() functions [`#1486`](https://github.com/oceanprotocol/ocean.js/pull/1486)
- Bump @types/node from 17.0.35 to 17.0.44 [`#1513`](https://github.com/oceanprotocol/ocean.js/pull/1513)
- Bump eslint-config-oceanprotocol from 1.5.0 to 2.0.1 [`#1466`](https://github.com/oceanprotocol/ocean.js/pull/1466)
- update to new schema & compute fixes [`#1510`](https://github.com/oceanprotocol/ocean.js/pull/1510)
- Release 1.1.2 [`85bf271`](https://github.com/oceanprotocol/ocean.js/commit/85bf2716e26d8691aeb9d5504e563d557419dc2e)
- manual bump fix [`5674a54`](https://github.com/oceanprotocol/ocean.js/commit/5674a547d1d367ce88b3595f0be8ebbf12274266)
- manual bump fix [`a362410`](https://github.com/oceanprotocol/ocean.js/commit/a36241004b1d9578ec5c02d9d6e64d9750c53a7b)
- Release 1.1.0 [`112c27e`](https://github.com/oceanprotocol/ocean.js/commit/112c27edab58ef0681ea3e87fb09978411924753)

#### [v1.0.0](https://github.com/oceanprotocol/ocean.js/compare/v1.0.0-next.45...v1.0.0)

Expand Down
5 changes: 4 additions & 1 deletion ComputeExamples.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ let resolvedDatasetDdo: DDO
let resolvedAlgorithmDdo: DDO

let computeJobId: string
let agreementId: string
```

### 4.3 Helper methods
Expand Down Expand Up @@ -661,6 +662,8 @@ Let's have 5 minute of compute access
Let's save the compute job it, we re going to use later
```Typescript
computeJobId = computeJobs[0].jobId
// eslint-disable-next-line prefer-destructuring
agreementId = computeJobs[0].agreementId

```

Expand All @@ -672,7 +675,7 @@ You can also add various delays so you see the various states of the compute job
providerUrl,
await consumerAccount.getAddress(),
computeJobId,
DATASET_DDO.id
agreementId
)
```
<!--
Expand Down
9 changes: 5 additions & 4 deletions docs/classes/Provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ ___

### computeStatus

▸ **computeStatus**(`providerUri`, `consumerAddress`, `jobId?`, `did?`, `signal?`): `Promise`<[`ComputeJob`](../interfaces/ComputeJob.md) \| [`ComputeJob`](../interfaces/ComputeJob.md)[]\>
▸ **computeStatus**(`providerUri`, `consumerAddress`, `jobId?`, `agreementId?`, `signal?`): `Promise`<[`ComputeJob`](../interfaces/ComputeJob.md) \| [`ComputeJob`](../interfaces/ComputeJob.md)[]\>

Get compute status for a specific jobId/documentId/owner.
Get compute status for a specific jobId/agreementId/owner.

#### Parameters

Expand All @@ -139,7 +139,7 @@ Get compute status for a specific jobId/documentId/owner.
| `providerUri` | `string` | The URI of the provider we want to query |
| `consumerAddress` | `string` | The consumer ethereum address |
| `jobId?` | `string` | The ID of a compute job. |
| `did?` | `string` | The ID of the asset |
| `agreementId?` | `string` | The ID of service agreement |
| `signal?` | `AbortSignal` | abort signal |

#### Returns
Expand All @@ -154,7 +154,7 @@ ___

### computeStop

▸ **computeStop**(`did`, `consumerAddress`, `jobId`, `providerUri`, `signer`, `signal?`): `Promise`<[`ComputeJob`](../interfaces/ComputeJob.md) \| [`ComputeJob`](../interfaces/ComputeJob.md)[]\>
▸ **computeStop**(`did`, `consumerAddress`, `jobId`, `providerUri`, `signer`, `signal?`, `agreementId?`): `Promise`<[`ComputeJob`](../interfaces/ComputeJob.md) \| [`ComputeJob`](../interfaces/ComputeJob.md)[]\>

Instruct the provider to Stop the execution of a to stop a compute job.

Expand All @@ -168,6 +168,7 @@ Instruct the provider to Stop the execution of a to stop a compute job.
| `providerUri` | `string` | The provider URI. |
| `signer` | `Signer` | The consumer signer object. |
| `signal?` | `AbortSignal` | abort signal |
| `agreementId?` | `string` | service agreement id |

#### Returns

Expand Down
4 changes: 2 additions & 2 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
@@ -1,7 +1,7 @@
{
"name": "@oceanprotocol/lib",
"source": "./src/index.ts",
"version": "3.3.2",
"version": "3.3.3-next.0",
"description": "JavaScript client library for Ocean Protocol",
"main": "./dist/lib.js",
"umd:main": "dist/lib.umd.js",
Expand Down
17 changes: 11 additions & 6 deletions src/services/Provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ export class Provider {
jobId: string,
providerUri: string,
signer: Signer,
agreementId?: string,
signal?: AbortSignal
): Promise<ComputeJob | ComputeJob[]> {
const providerEndpoints = await this.getEndpoints(providerUri)
Expand All @@ -643,12 +644,16 @@ export class Provider {

let signatureMessage = consumerAddress
signatureMessage += jobId || ''
signatureMessage += (did && `${this.noZeroX(did)}`) || ''
signatureMessage += nonce
// On current provider impl (and nodes) we DO NOT check this signature
// On nodes we are signing again just the Nonce to send the request to Operator Service
// on current provider we sign: {owner}{job_id}{nonce}" OR {owner}{nonce} if no jobId
// On provider service STOP route, we just check signature owner + jobId OR just owner if no jobId
// signatureMessage += (agreementId && `${this.noZeroX(agreementId)}`) || ''
// signatureMessage += nonce
const signature = await this.signProviderRequest(signer, signatureMessage)
const payload = Object()
payload.signature = signature
payload.documentId = this.noZeroX(did)
payload.agreementId = this.noZeroX(agreementId)
payload.consumerAddress = consumerAddress
payload.nonce = nonce
if (jobId) payload.jobId = jobId
Expand Down Expand Up @@ -688,15 +693,15 @@ export class Provider {
* @param {string} providerUri The URI of the provider we want to query
* @param {string} consumerAddress The consumer ethereum address
* @param {string} jobId The ID of a compute job.
* @param {string} did The ID of the asset
* @param {string} agreementId The ID of the service agreement (tx id)
* @param {AbortSignal} signal abort signal
* @return {Promise<ComputeJob | ComputeJob[]>}
*/
public async computeStatus(
providerUri: string,
consumerAddress: string,
jobId?: string,
did?: string,
agreementId?: string,
signal?: AbortSignal
): Promise<ComputeJob | ComputeJob[]> {
const providerEndpoints = await this.getEndpoints(providerUri)
Expand All @@ -709,7 +714,7 @@ export class Provider {
: null

let url = `?consumerAddress=${consumerAddress}`
url += (did && `&documentId=${this.noZeroX(did)}`) || ''
url += (agreementId && `&agreementId=${this.noZeroX(agreementId)}`) || ''
url += (jobId && `&jobId=${jobId}`) || ''

if (!computeStatusUrl) return null
Expand Down
5 changes: 4 additions & 1 deletion test/integration/ComputeExamples.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ let resolvedDatasetDdo: DDO
let resolvedAlgorithmDdo: DDO

let computeJobId: string
let agreementId: string
/// ```

/// ### 4.3 Helper methods
Expand Down Expand Up @@ -661,6 +662,8 @@ describe('Compute-to-data example tests', async () => {
/// Let's save the compute job it, we re going to use later
/// ```Typescript
computeJobId = computeJobs[0].jobId
// eslint-disable-next-line prefer-destructuring
agreementId = computeJobs[0].agreementId
}) ///
/// ```

Expand All @@ -672,7 +675,7 @@ describe('Compute-to-data example tests', async () => {
providerUrl,
await consumerAccount.getAddress(),
computeJobId,
DATASET_DDO.id
agreementId
)
/// ```
/// <!--
Expand Down
4 changes: 2 additions & 2 deletions test/integration/PublishEditConsume.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const ifpsFile: Files = {
files: [
{
type: 'ipfs',
hash: 'QmdMBw956S3i2H2ioS9cERrtxoLJuSsfjzCvkqoDgUa2xm'
hash: 'QmRhsp7eghZtW4PktPC2wAHdKoy2LiF1n6UXMKmAhqQJUA'
}
]
}
Expand Down Expand Up @@ -222,7 +222,7 @@ describe('Publish consume test', async () => {
addresses.ERC721Factory,
aquarius
)
assert(urlAssetId, 'Failed to publish ipfs DDO')
assert(ipfsAssetId, 'Failed to publish ipfs DDO')
})

it('Should publish arwave asset', async () => {
Expand Down
Loading