ocean.js
ocean.js copied to clipboard
Code Examples C2D computeStart error: order for serviceId 2 is not valid
Describe the bug
I am trying to run the C2D flow as described in this guide https://github.com/oceanprotocol/ocean.js/blob/06ac192ae0e85f861c6b1b053b76f59c00e211e6/C2DExamples.md#-resolve-published-datasets-and-algorithms. I needed to refactor some of the code because I am using a pre-release of ocean.js which has a completely different specification for approveWei
. I am able to run the entire flow up to computeStart, where I get the following error:
Order for serviceId 2 is not valid. Cannot find the event for the provider fee in tx id 0xdf429177febdcfb60681d82a8fdf0f4eafc0627ceda2f449212e74c3dac63102..
I think the only main difference between my code and the example is my handleOrder
function, but I am not sure what the issue is. The code is available here https://github.com/AlgoveraAI/streamlit-ocean/blob/main/streamlit_ocean/frontend/src/OceanCompute.tsx#L372.
To Reproduce Steps to reproduce the behavior:
- Go to https://github.com/AlgoveraAI/streamlit-ocean
- Follow installation instruction
- Open the browser app and click connect wallet (make sure you're on rinkeby)
- In the running browser app, insert the following CIDs: did:op:95de9183c7ab66bf31595d4799eeb594994f9194ab6f9f69d34adc561845800e -> dataset did:op:8be3d6e5b688cbe00ba8945eb06a8a5e31cfa8095e198f7e9515185711884214 -> algorithm
- Click on Run Compute
- In the console, see error
Expected behavior C2D starts correctly
Update
I tried sending the datatokens & algorithm tokens manually from a test wallet in ocean.py to my MetaMask test wallet, that meant my script was not attempting to buy or gain access to the datatokens & we only approve the provider fee and run datatoken.startOrder
. With this workflow, C2D started correctly and the above error disappeared.
I think this means whatever error I have, it's in the part of the code for handling order for a datatoken that is not in my wallet. Since I haven't found any guides on how to do general order handling on rinkeby, I copied some of the code from the market, but since I wasn't able to reproduce working C2D in the market frontend, I presume a similar error is reflected in my code. The buying is being handled here: https://github.com/AlgoveraAI/streamlit-ocean-compute/blob/main/streamlit_ocean_compute/frontend/src/OceanCompute.tsx#L474. Thanks for any advice/suggestions.
Hi, based on what i can see in the repo, first thing is that you just need to call just the approveWei
for the provider fees https://github.com/AlgoveraAI/streamlit-ocean-compute/blob/9a65307ce7c8543a0b5ec1435fdbce1ae37ce0f5/streamlit_ocean_compute/frontend/src/OceanCompute.tsx#L395 and another thing would be to use the datatoken address for the 5'th param here https://github.com/AlgoveraAI/streamlit-ocean-compute/blob/9a65307ce7c8543a0b5ec1435fdbce1ae37ce0f5/streamlit_ocean_compute/frontend/src/OceanCompute.tsx#L413 when calling the approveWei
method.
Also you no longer need to do this check https://github.com/AlgoveraAI/streamlit-ocean-compute/blob/9a65307ce7c8543a0b5ec1435fdbce1ae37ce0f5/streamlit_ocean_compute/frontend/src/OceanCompute.tsx#L440 you just need to rely on valid order and provider fee provider fee amount to check if you need to call order or reuse order and also approve provider fees if necessary.
Hi @bogdanfazakas, thanks a lot for the reply! I tried making the changes you proposed, but the error still persists. Removing the check of datatokens and just going straight to await datatoken.startOrder
outputs an error:
execution reverted: Not enough datatokens to start Order
On the other hand, if the wallet does have datatokens, datatoken.startOrder
is the only function that returned a transaction ID that the provider accepted for ProviderInstance.computeStart
. I changed my approveProviderFee
based on your suggestions to this:
const approveProviderFee = async () => {
console.log("Approving provider fee")
console.log("provider fee", order.providerFee)
// Approve provider fees if exists
// if (order.providerFee && order.providerFee.providerFeeAmount) {
// await datatoken.approve(
// order.providerFee.providerFeeToken,
// datatokenAddress,
// order.providerFee.providerFeeAmount,
// payerAccount
// );
const config = await getTestConfig(web3)
await approveWei(
web3,
config,
payerAccount,
order.providerFee.providerFeeToken,
datatokenAddress,
order.providerFee.providerFeeAmount,
// datatokenAddress,
)
// }
};
however, its execution in the buyAndOrder
still results in the same error Order for serviceId 2 is not valid. Cannot find the event for the provider fee in tx id ...
.
Do you think adding datatoken.startOder
at the end of buyAndOrder
could solve the issue? Or do you have any other suggestions/code examples which show how to buy both fixedRateExchange & free datatokens on the marketplace? I should note that I'm using "@oceanprotocol/lib": "2.0.0-next.0"
as recommended by @jamiehewitt15 which I believe has slightly different variables in some of the functions, like approveWei
.
@smejak is this issue still relevant? Based on the discord i understood that you were able to order and start c2d jobs
@bogdanfazakas Yes, the issue is still relevant, the C2D does not work when I attempt to buy datatokens with the buyAndOrder
function, do you have any resources where datatoken buying (both free and fixed rate exchange) combined with starting a compute job works?
Hi @smejak! sorry for the late reply. @bogdanfazakas is working right now on the C2D readme that will help you navigate through this issue. Will share it once is done. Thanks for your patience!
@bogdanfazakas Please take a look at this issue. I think it's fixed but let's double check
Hi @smejak , not sure if this is still an issue, but if the issue persists please take a look at the following section in Compute examples readme https://github.com/oceanprotocol/ocean.js/blob/main/ComputeExamples.md#43-helper-methods more precisely at the handleOrder
. if still the issue persists please reopen the issue add more updates to the issue.