Irys-xyz / arweave-js-sdk

JS SDK for Irys on Arweave
110 stars 95 forks source link

GraphQL query not returning proper values based on tags after being posted then mined with Bundlr + Arweave #35

Closed dabit3 closed 2 years ago

dabit3 commented 2 years ago

Hi, so I've been trying out the bundlr JS client, specifically the WebBundlr client, and I'm experiencing issues having the data mined to the network.

I've also noticed that there are a couple of different ways you all have referenced sending a transaction. For example, in the demo application you use this syntax:

await bundler?.uploader.upload(img, [{ name: "Content-Type", value: "image/png" }])

But in the documentation I see this:

const transaction = bundlr.createTransaction(data, { tags });

await transaction.sign();
await transaction.upload();

As for me, I've tried both, and am not sure if there is also maybe something I'm doing wrong in my code. Here's a look at essentially what I'm doing:

async function connect() {
    await window.ethereum.request({ method: 'eth_requestAccounts' })
    const provider = new providers.Web3Provider(window.ethereum);
    await provider._ready()

    const bundlr = new WebBundlr("https://node1.bundlr.network", "matic", provider)
    await bundlr.ready()

    setBundlrInstance(bundlr)
  }

/* create a transaction (plain text, JSON, file, image, video, etc..) */
async function createTransaction() {
  const data = "hello world"
  const tags = [
    { name: 'App-Name', value: 'PublicSquare' },
    { name: 'Content-Type', value: 'text/plain' },
    { name: 'Version', value: '1.0.1' },
    { name: 'Type', value: 'post' }
  ]

  const transaction = bundlrInstance.createTransaction(data, { tags })

  await transaction.sign()
  await transaction.upload()

  console.log('transaction id: ', transaction.id)
}

The data seems to be saving to the network, but after a while it is dropped.

I have had one or two transactions mined, but I've been doing so much experimentation I'm not sure why those worked but my others did not.

Is there anything that I should know that might help me understand better how this works?

Thanks for your time.

joshbenaron commented 2 years ago

Hey @dabit3! Would you be able to provide some tx IDs that we can check please? There are lots of components which could be amiss here (outside of Bundlr). Including the gateway etc.

dabit3 commented 2 years ago

Hey, sure. Here is some recent transaction information:

1. id: U3z0fpSWYREVNyv_0I2yjRtd4rzuMV9BnX3tYqoAOaQ block: 906695

  1. id: mEiGk7VPZ89g8OCHRodfntvBum3CUOKn2bXxCBjutjA block: 906699

For some context - the goal is to rebuild the example application that is set up in the Arweave documentation, the Twitter app built on Arweave. https://arwiki.wiki/#/en/creating-a-dapp-02

Submitting the transaction seems to work, when I query it shows up, but after a while (around an hour) it drops.

joshbenaron commented 2 years ago

Hey,

The data appears to be available (i.e. not dropped). e.g. https://arweave.net/mEiGk7VPZ89g8OCHRodfntvBum3CUOKn2bXxCBjutjA https://arweave.net/U3z0fpSWYREVNyv_0I2yjRtd4rzuMV9BnX3tYqoAOaQ

How are you testing whether a transaction exists or not?

dabit3 commented 2 years ago

Ok interesting. Here's more details:

First, I create a transaction. Then when I run the query, the data is returned fine and the block height is initially set to -1.

Screen Shot 2022-04-04 at 6 37 22 PM

After some time, the query no longer returns the result in the selection set.

Here is the query I'm running:

{
  query: `{
    transactions(first: 50,
      tags: [
        {
          name: "App-Name",
          values: ["PublicSquare"]
        },
        {
          name: "Content-Type",
          values: ["text/plain"]
        }
      ]
    ) {
      edges {
        node {
          id
          owner {
            address
          }
          data {
            size
          }
          block {
            height
            timestamp
          }
          tags {
            name,
            value
          }
        }
      }
    }
  }`
}

Here are a couple of new transaction IDs:

0MtwwGCAGZUZa3ZLpNRikaBbQPT1eXguqhDY_Szh-N4
3DBDf-L5ilOt4Hy-NjjkVOQxfjPtXkaWKF-8SCvfxB4
joshbenaron commented 2 years ago

Ah - GraphQL. We've seen some issues here recently. So Bundlr is separate from arweave.net - in the sense that it's nor our codebase, nor our infrastructure so it's out of our control. I've flagged an issue with the team that maintains arweave.net

dabit3 commented 2 years ago

Ah ok interesting, I'll also flag this with them.

joshbenaron commented 2 years ago

Just for further clarity. Bundlr txs have a -1 height until they hit L1. But sometimes the gateway can miss Bundlr txs and think that it never hit Arweave (when it does)

joshbenaron commented 2 years ago

I'd actually be able to tell you the specific tx ids of the bundles those Bundlr txs were included in and which miners on the network are storing them

dabit3 commented 2 years ago

Ah ok interesting... I may try a new set of tags and queries just out of curiosity to see if that changes things for any reason at all. If there's anything else I can add or help with in terms of troubleshooting please let me know.

I am creating some educational material / resources around this tech stack and think that this combination is going to be important for me to use so I'd love to understand how to make it all work properly together.

joshbenaron commented 2 years ago

You may want to try again now. I've just lowered bundle size so the gateway should be able to more easily find Bundlr txs

dabit3 commented 2 years ago

Ok cool thank you, giving it another shot and will report back by tomorrow, thanks for all of your help thus far!

dabit3 commented 2 years ago

Hey @joshbenaron update: yes, this is working for me now! Thank you for your help.

Question: is this something that I should consider when creating educational content around using the GraphQL interface for Arweave going forward or is this more of a uncommon scenario that will not affect most users?

dabit3 commented 2 years ago

Not 100% certain just yet, but I feel like I may be running into this issue again on another combination of query / tags. Any ideas if something changed since the last time you updated the gateway?

dumbfounder commented 2 years ago

We are also having this issue testing bundlr with the following tx's: AV3Q6gMkO4BlZE2dze0Ai5HF3wPmRnsTU5wQlmvlhgM mv57cCG5ZvUzcCA169olWh1x5IdE024EiARntvQblAo 9sljLRwddnQ0WxPOeZ9gNRhbX2XU3clE3KRR_-KkUvE E9Js_5P-Gj3Y_P5ZKZCCv7JJIGWgjRpKBMg9f_tsnMI 2qrnGycd7k6ckapI-RMBVPHRpgYBcENRuaFchNMxMzg They showed up for a while in arweave.net/graphql (optimistically cached) but then disappeared. We can download the files though ok. Not available in viewblock either (but also not sure if viewblock supports bundled tx's).

We are seeing this happen for every tx we have tried.

dabit3 commented 2 years ago

bump

dabit3 commented 2 years ago

Seems like this is working now for me so will close the issue