permaweb / ao

The ao component and tools Monorepo - 🐰 🕳️ 👈
https://cookbook_ao.arweave.dev
Other
189 stars 61 forks source link

Assignments sometimes not sent to Arweave (first interaction to process?) #787

Closed keikari closed 4 months ago

keikari commented 5 months ago

Sometimes assignments created as a result to a message don't get send to Arweave.
One common thing with following examples is that the all the missing assignments were first interactions to their target processes. So far haven't been able to repro the issue when using locally hosted MU. Only with https://mu.ao-testnet.xyz

Examples:

1. This result has 22 assignments + 1 message, but I only 12 assignments of the message can be seen in GraphQL (including the original one)

https://cu.ao-testnet.xyz/result/A776zSKWdBxdcTQU2YwAUINs-z6ttMe4Nc3PMKbug7U?process-id=E9JyfY7fAuyVKmEOZp_mMaMZkLE_f2wuj0A8icDynao


2. This result has 25 assignments + 1 message. Only the message was created. For assignments, can only find the original assignment for the message on GraphQL.

https://cu.ao-testnet.xyz/result/-c8LRsspay9Sm798tx08jSQa5HtYMN599aN3BTcKdPM?process-id=u5gcUgvzB9vzHvXlB0ohyASFbI02v_e3E86Lz6hTwiw


  1. First try: using locally hosted MU -> created all assignments Second try: using https://mu.ao-testnet.xyz -> no assignments found on GraphQL (Following try using https://mu.ao-testnet.xyz worked normally)

First result, on local MU, all the assignments created can be found on GraphQL as expected: https://cu.ao-testnet.xyz/result/vXwUZFXqjv4ws-i-srylBvMXHSverV-SnDyl5pspVCc?process-id=6rcGHNizsWqq3nZwSzj8SC8E7Rv_dsnWq3pEu_XbrQ8

Second result, on the default MU, none of the new assignments can be found on GraphQL: https://cu.ao-testnet.xyz/result/uSB07yWfI_LdS_AX17l6krGGGQfq4qvHdD3a-3gSEQw?process-id=6rcGHNizsWqq3nZwSzj8SC8E7Rv_dsnWq3pEu_XbrQ8


Made a small Node.js script to repro the issue, just needs path to some wallet set and required modules installed, and can just be run. It may take few attempts to get the issue to happen.

What it does:

  1. Creates two processes
  2. Adds handler to the processA, which will send a new message to itself and assign the current message to processB.
  3. Sends message to processA to trigger the handler.

Example result with an issue from the script: https://cu.ao-testnet.xyz/result/2qVomOuqqCiPp7WzZpA9GhWK9Wn_95R7Ps5I0OFqu4w?process-id=_rr8UYVLmLeZhl5mInG1JLE6NzB9udJXKFL9vPdXm_Q

Script ```js const aoConnect = require("@permaweb/aoconnect"); const fs = require("node:fs"); const walletPath = "./wallet.json" async function main() { const wallet = JSON.parse( fs.readFileSync(walletPath).toString(), ); const { assign, result, results, message, spawn, monitor, unmonitor, dryrun } = await aoConnect.connect( { MU_URL: "https://mu.ao-testnet.xyz", CU_URL: "https://cu.ao-testnet.xyz", GATEWAY_URL: "https://arweave.net", }, ); // 1. Create 2 process console.log("Creating processes"); const pidA = await spawn({ module: "nI_jcZgPd0rcsnjaHtaaJPpMCW847ou-3RGA5_W3aZg", scheduler: "_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA", signer: aoConnect.createDataItemSigner(wallet), }) .catch(console.error); const pidB = await spawn({ module: "nI_jcZgPd0rcsnjaHtaaJPpMCW847ou-3RGA5_W3aZg", scheduler: "_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA", signer: aoConnect.createDataItemSigner(wallet), }) .catch(console.error); console.log("pidA:", pidA); console.log("pidB:", pidB); console.log(); // Wait a bit for a process to exist on gateway console.log("Waiting 5s to make sure processes can be found on gateway\n") await new Promise(r => setTimeout(r, 5000)); // 2. Set handler on the process A await message({ process: pidA, tags: [{ name: "Action", value: "Eval" }], signer: aoConnect.createDataItemSigner(wallet), data: ` Handlers.add( "test-action", Handlers.utils.hasMatchingTag("Action", "Test-Action"), function (m) ao.send({Target = ao.id, Data="This message is used to confirm that the result was seen on MU"}) ao.assign({Processes = { "${pidB}" }, Message = m.Id}) end )`, }) .then((id) => { console.log("Handler added"); console.log(`https://cu.ao-testnet.xyz/result/${id}?process-id=${pidA}\n`) }) .catch(console.error); // 3. Trigger handler on process A await message({ process: pidA, tags: [{ name: "Action", value: "Test-Action" }], signer: aoConnect.createDataItemSigner(wallet), data: "", }) .then((id) => { console.log("Assignment from this sometimes isn't found on Arweave") console.log(`https://cu.ao-testnet.xyz/result/${id}?process-id=${pidA}`) console.log(); }) .catch(console.error); } main(); ```
keikari commented 5 months ago

Also assignment from this is missing from GraphQL: https://cu.ao-testnet.xyz/result/l0ECqndw41mzj7wUlL0Rt8uwcPXTilP9SlYBowdYgw4?process-id=USeBAOJjR-7F6mfre3VzBmFZhsWb42kdyeuvSugi5T8

Difference to other examples is that it wasn't first time the target process of the assignment was used. So don't know if same or different issue.

jfrain99 commented 4 months ago

Hello @keikari! Thank you for the issue! Some time has passed and I'm having trouble recreating the bug - are you still able to recreate this issue?

keikari commented 4 months ago

Yeah, still able to recreate it. Ran the script from the first post 3 times, and on the third time the assignment didn't got into Arweave.

https://cu.ao-testnet.xyz/result/HVhXQsUk12BnMv8SWGZpXrY08_6ETc_qACj97-cMwPc?process-id=-dJpC4WTEtk6Q0p1OOtu3cINREd1dcJuvBD-_1fM-a4

Can't find the assignment of HVhXQsUk12BnMv8SWGZpXrY08_6ETc_qACj97-cMwPc to process OT8Z_DFCbxN3I4qgG5urP6HtJ__A7USyfXwlHe9Wnrw from graphQL

jfrain99 commented 4 months ago

Hello @keikari, a fix for this is now deployed (#810). Thank you for your report!

keikari commented 4 months ago

Should it be in effect by now in the default nodes?
Was still able to reproduce the issue just now.

Assignment from this isn't found from Graphql. https://cu.ao-testnet.xyz/result/V4N2QE9uP0gnnhpfHKXbnDG12AZmCwKAnm71r5Rs22I?process-id=0TpKTbIW7mo_A0_rY8oSosSzsskE16F-i9zMqWjbCjk