Skip to content

Feature/escrow_payments#828

Merged
alexcos20 merged 111 commits intomainfrom
feature/escrow_payments
Apr 15, 2025
Merged

Feature/escrow_payments#828
alexcos20 merged 111 commits intomainfrom
feature/escrow_payments

Conversation

@alexcos20
Copy link
Copy Markdown
Member

@alexcos20 alexcos20 commented Jan 30, 2025

Changes proposed in this PR:

  • remove OPF_k8
  • add escrow payments
  • update interfaces for paid Compute Jobs (BREAKING CHANGES)

How to use:

  • start barge with
export CONTRACTS_VERSION=escrow
./start_ocean.sh --no-aquarius --no-provider --no-dashboard --with-typesense

Nice TODOs (can be done later):

  • more tests for lock/claim
  • docs

Copy link
Copy Markdown
Contributor

@mariacarmina mariacarmina left a comment

Choose a reason for hiding this comment

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

I left some comments, still need to review feesHandler & and test the end2end flow, because it contains many breaking changes.

Comment thread src/components/c2d/compute_engine_base.ts
const signer = blockchain.getSigner()
const contract = await this.getContract(chainId, signer)
try {
return await contract.getAuthorizations(token, payer, payee)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Those functions, at least most of them are implemented here, when a new ocean.js version will be released, I would say that contract object creation and calling contract function to be replaced with the methods in ocean.js. In ocean.js I can also add the additional checks that you managed to write within ocean-node.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

what's the relation? ocean-node does not use ocean.js

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't remember why we decided not to use ocean.js in ocean node? I can see that it would avoid duplication if we imported these functions from ocean.js rather than maintaining them in both places

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@alexcos20 it is helpful to use the lib when we interact with smart contracts, at least that's a suggestion, we also have ethers in ocean-node to interact with smart contracts. I've just seen that some similar functions from ocean-node for escrow payments (and not only) that can be imported from ocean.js

Copy link
Copy Markdown
Contributor

@paulo-ocean paulo-ocean Feb 17, 2025

Choose a reason for hiding this comment

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

well, i actually disagree on this.. IMO is better to NOT use the SDK on the nodes, AS IS... otherwise we might have to keep SDK updated (and release a new version) every time we do a big change on the Nodes... Every contract is different and has different functions, we don't need the SDK to interact with a smart contract..

we have ethers for that.. If we're gonna use the SDK on the Nodes... we might have issues, as we need to keep always 4 different pieces of software in sync; the SDK, the CLI (which we also use for the system tests) , the Smart Contracts and the Nodes, .... and we certainly don't need all the extra functionality available on the SDK whe we just need to call a smart class function..

Are we actually discussing introducing the SDK dependency because of one single function that creates a smart contract instance??? this.getContract(..) ? (cause all the rest is the same but with the overhead of creating further classes)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's an interesting discussion, I think it depends if it could be useful in multiple places and not just one instance. I don't quite see it the same as you @paulo-ocean

otherwise we might have to keep SDK updated (and release a new version) every time we do a big change on the Nodes

That shouldn't be the case, if the SDK covers all of the functionality in the contracts the only thing that you would change would be the arguments that you are passing to the SDK functions, no need for a new release. The new release of the SDK would just be when the contracts are updated.

we might have issues, as we need to keep always 4 different pieces of software in sync; the SDK, the CLI (which we also use for the system tests) , the Smart Contracts and the Nodes

  1. The SDK should always be up-to-date with the contracts anyway, otherwise, what's the point in having it?
  2. The CLI already uses ocean.js to interact with the contracts, so there is no extra work there.

So it's only a question of if the nodes could benefit from using the SDK. And it shouldn't create extra work, if there is a function in the SDK that is duplicated here it reduces the amount of code that we need to maintain if it is imported.

Are we actually discussing introducing the SDK dependency because of one single function that creates a smart contract instance???

I agree with this - it's not worth it for one function call, only if it's going to be used in multiple places.

Copy link
Copy Markdown
Contributor

@paulo-ocean paulo-ocean Feb 17, 2025

Choose a reason for hiding this comment

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

Its ok that we have different views :-)
I personally don't see any need for SDK on the nodes, and i think it will bring more way more issues than solutions.
Afaik, the SDK is mainly a library to abstract indexer, provider, aquarius, etc.. deal with configurations, URLS, etc..
This is all part of the nodes monolithic infrastructure... don´t see how its helpful here

Regarding the smart contracts in particular, I don't think we need an SDK to encapsulate every smart contract functionality into a typescript class, just to eventually call a smart contract function. And i definitely don't see that as a code duplication...

its just an enclosing function to call the smart contract level function.. If we use the SDK for this particular case its exactly the same thing... except that we have an extra Instance in memory, and we call the encapsulating function that actually does the smart contract call... And if we need a bit more logic on the node side, what do we do then? We update the SDK? Because if we don't we probably already lost the sdk "benefit" here anyway

Anyway, my 2 cents... doesn't mean i'm right or wrong

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Why we would integrate ocean-js in ocean-node? For 3 (three) functions in a smartcontract? Which, for now, don't even overlap? (ie: they do not exist in ocean.js)

@jamiehewitt15
Copy link
Copy Markdown
Contributor

We will need some documentation on how the escrow payments work, is that going to come in a separate PR?

console.log('timeNow: ' + timeNow + ' , Expiry: ' + job.expireTimestamp)
if (timeNow > job.expireTimestamp || job.stopRequested) {
const expiry = parseFloat(job.algoStartTimestamp) + job.maxJobDuration
console.log('timeNow: ' + timeNow + ' , Expiry: ' + expiry)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why are you using console.log rather than our CustomNodeLogger?

Comment on lines +80 to +108
return {
stream: null,
status: {
httpStatus: 500,
error: 'Invalid C2D Environment'
}
}
}
if (engine === null) {
return {
stream: null,
status: {
httpStatus: 500,
error: 'Invalid C2D Environment'
}
}
}
try {
env = await engine.getComputeEnvironment(task.payment.chainId, task.environment)
if (!env) {
return {
stream: null,
status: {
httpStatus: 500,
error: 'Invalid C2D Environment'
}
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be good if each of these 500 responses had a different error message so we know exactly where it is coming from and which check failed.

Comment on lines +364 to +365
// TO DO: Edge case when this asset is served by a remote provider.
// We should connect to that provider and get the fee
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like this was left here from before your changes, is it still the plan? If so we need an issue for it

try {
const funds = await contract.getUserFunds(payer, token)
return funds.available
} catch (e) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there any reason why you didn't log the errors in any of the functions in this file? It's going to make it hard to debug when something isn't working...

Comment thread src/components/database/sqliteCompute.ts Outdated
Comment thread src/OceanNode.ts

// eslint-disable-next-line no-useless-constructor
private constructor(
private config: OceanNodeConfig,
Copy link
Copy Markdown
Contributor

@paulo-ocean paulo-ocean Feb 13, 2025

Choose a reason for hiding this comment

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

why do we need to add the config? we already did the same change a couple of times in the past.. but the config is something that can change over time (very frequent on the tests).. The initial idea was to create a node Instance based on the initial config
Afaik, its only usage here is to "decide" if we should also add both C2D engines and Escrow components... so why not add those on the constructor (like we do for other optional components, like; P2P, DB, Indexer, etc ?)... like:

public static getInstance(
   //  config?: OceanNodeConfig,
    db?: Database,
    node?: OceanP2P,
    provider?: OceanProvider,
    indexer?: OceanIndexer,
    c2dEngines?: C2DEngines,
   escrow?: Escrow
  ): OceanNode {

this ways its the same approach for all components
we also have this piece in the constructor

if (this.config) {
      this.escrow = new Escrow(
        this.config.supportedNetworks,
        this.config.claimDurationTimeout
      )
}

but the config is not optional and there is always a configuration object when we start a node.. so the escrow creation is kind of mandatory anyway

Comment thread docs/env.md

## Payments

- `ESCROW_CLAIM_TIMEOUT`: Amount of time reserved to claim a escrow payment, in seconds. Defaults to `600`. Example: `600`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i think we should also add the variable reference to constants/ENVIRONMENT_VARIABLES, env.example and scripts/ocean-node-quickstart.sh

Comment thread src/@types/C2D/C2D.ts
Co-authored-by: Jamie Hewitt <jamie@oceanprotocol.com>
Base automatically changed from feature/docker_refactor to feature/c2d_docker February 25, 2025 07:32
Copy link
Copy Markdown
Contributor

@mariacarmina mariacarmina left a comment

Choose a reason for hiding this comment

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

At initializeCompute https://github.com/oceanprotocol/ocean-node/pull/828/files#diff-71521de5df77d93ae85ff75f78504f70beec812c2e776bf25e990a0d5d4c37b8R284 we do not create any task object specific for compute initialize, I'd suggest to have some checks for the following keys: 'payment', 'consumerAddress', 'environment' -> then we can update also the API.md for compute routes to be easier to follow the parameters.

Base automatically changed from feature/c2d_docker to main March 21, 2025 13:44
@alexcos20 alexcos20 requested a review from giurgiur99 as a code owner March 21, 2025 13:44
Copy link
Copy Markdown
Contributor

@mariacarmina mariacarmina left a comment

Choose a reason for hiding this comment

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

One question from my side, otherwise it's good to start with this baseline and not keeping in review for too much time.

Comment thread .github/workflows/ci.yml
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Run Barge
working-directory: ${{ github.workspace }}/barge
env:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we can update barge with default version to escrow? Or after we have this escrow integration in place and see if works on all impacted repos?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I will take care of this

@alexcos20 alexcos20 merged commit e18ddc8 into main Apr 15, 2025
13 checks passed
@alexcos20 alexcos20 deleted the feature/escrow_payments branch April 15, 2025 03:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Escrow integration

7 participants