Conversation
mariacarmina
left a comment
There was a problem hiding this comment.
I left some comments, still need to review feesHandler & and test the end2end flow, because it contains many breaking changes.
| const signer = blockchain.getSigner() | ||
| const contract = await this.getContract(chainId, signer) | ||
| try { | ||
| return await contract.getAuthorizations(token, payer, payee) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
what's the relation? ocean-node does not use ocean.js
There was a problem hiding this comment.
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
There was a problem hiding this comment.
@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
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
- The SDK should always be up-to-date with the contracts anyway, otherwise, what's the point in having it?
- 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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
|
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) |
There was a problem hiding this comment.
Why are you using console.log rather than our CustomNodeLogger?
| 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' | ||
| } | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
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.
| // TO DO: Edge case when this asset is served by a remote provider. | ||
| // We should connect to that provider and get the fee |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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...
|
|
||
| // eslint-disable-next-line no-useless-constructor | ||
| private constructor( | ||
| private config: OceanNodeConfig, |
There was a problem hiding this comment.
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
|
|
||
| ## Payments | ||
|
|
||
| - `ESCROW_CLAIM_TIMEOUT`: Amount of time reserved to claim a escrow payment, in seconds. Defaults to `600`. Example: `600` |
There was a problem hiding this comment.
i think we should also add the variable reference to constants/ENVIRONMENT_VARIABLES, env.example and scripts/ocean-node-quickstart.sh
Co-authored-by: Jamie Hewitt <jamie@oceanprotocol.com>
mariacarmina
left a comment
There was a problem hiding this comment.
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.
mariacarmina
left a comment
There was a problem hiding this comment.
One question from my side, otherwise it's good to start with this baseline and not keeping in review for too much time.
| DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
| - name: Run Barge | ||
| working-directory: ${{ github.workspace }}/barge | ||
| env: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
I will take care of this
Changes proposed in this PR:
How to use:
export CONTRACTS_VERSION=escrow ./start_ocean.sh --no-aquarius --no-provider --no-dashboard --with-typesenseNice TODOs (can be done later):