ar-io / arns-service

Koa microservice that leverages Warp to support the ArNS Portal and ar.io observers.
https://api.arns.app
GNU Affero General Public License v3.0
19 stars 4 forks source link

fix(graphql): use warp `TagParser` to properly handle multi contract input tags #64

Closed atticusofsparta closed 9 months ago

atticusofsparta commented 9 months ago

This uses warp-contract TagsParser to correctly fetch input tags in the event of multi-write interactions, those being smartweave interactions that are performing writes to more than one contract at once.

Currently there is an issue with ar-io.dev where graphql returns incorrectly ordered information in the node interface, specifically the tags interface, resulting in the incorrect interaction being identified in from the tags.

In this pr I set the gateway to arweave.net for testing, to see the differences in interactions fetching compare the following endpoints and to a search for setRecord while running the service locally on localhost:3000 :

You will notice api.arns.app returns references to 'setRecord' - if you take the ID's from those and do a search on localhost you will see the correct inputs for the interactions.

this demonstrates two things, the return difference between ar-io.dev and arweave.net from the graphql endpoint, but also mis-parsed tags.

to directly see the difference in graphql returns you can go to ar-io.dev/graphql and arweave.net/graphql respectively and run the following query:

query {
  transactions(first: 1, sort: HEIGHT_DESC
    ids:["7mQttmhoB4xEuaUX4paR12xgqlYo9Vxmpgk03wAvIUY"]
  )
  {

    pageInfo{
     hasNextPage
    }

    edges {
      cursor
      node {
        bundledIn {
          id
        }
        block {
          height
        }
        id
        owner {
              address
                }
        tags {
          name
          value
        }
      }
    }
  }
}
dtfiedler commented 9 months ago

api.dev.arns.app/v1/contract/bLAgYxAdX2Ry-nt6aH2ixgvJXbpsEYm28NgJgyqfs-U with ar-io.dev.

{
"height": 1308614,
"input": {
"function": "setRecord",
"subDomain": "@",
"transactionId": {
"transactionId": "_zaE8Djb71W9YogzH1gMI9nAo0PuHATKcyrJiDhBG5M"
},
"ttlSeconds": 900
},
"owner": "7leENbll3b2aU6bB9rOMLSGLbmWGkMym2Hyz4m_Et2k",
"valid": false,
"error": "No function supplied or function not recognized: \"setRecord\"",
"id": "7mQttmhoB4xEuaUX4paR12xgqlYo9Vxmpgk03wAvIUY"
},

localhost with ar-io.dev:

{
"height": 1308614,
"input": {
"function": "setRecord",
"subDomain": "@",
"transactionId": {
"transactionId": "_zaE8Djb71W9YogzH1gMI9nAo0PuHATKcyrJiDhBG5M"
},
"ttlSeconds": 900
},
"owner": "7leENbll3b2aU6bB9rOMLSGLbmWGkMym2Hyz4m_Et2k",
"valid": false,
"error": "No function supplied or function not recognized: \"setRecord\"",
"id": "7mQttmhoB4xEuaUX4paR12xgqlYo9Vxmpgk03wAvIUY"
},

localhost with arweave.net:

{
"height": 1308614,
"input": {
"function": "setRecord",
"subDomain": "@",
"transactionId": {
"transactionId": "_zaE8Djb71W9YogzH1gMI9nAo0PuHATKcyrJiDhBG5M"
},
"ttlSeconds": 900
},
"owner": "7leENbll3b2aU6bB9rOMLSGLbmWGkMym2Hyz4m_Et2k",
"valid": false,
"id": "7mQttmhoB4xEuaUX4paR12xgqlYo9Vxmpgk03wAvIUY"
},
atticusofsparta commented 9 months ago

@dtfiedler thats odd, none of the setRecord interactions before were applied - according to the tags, this shouldnt even be getting applied. Actually, this interaction should even been getting left in, our tags parser should pull them out - was that on this branch or another one?

dtfiedler commented 9 months ago

@atticusofsparta - updated, had to clear the cache and use arweave.net but we should only see the input that warp does evaluate.

atticusofsparta commented 9 months ago

@dtfiedler bizzare - running again myself, something seems off here.

atticusofsparta commented 9 months ago

@dtfiedler i had to update my .env file to point to arweave.net as well, when i do this is what i get for that txid

{
"height": 1308614,
"input": {
"function": "buyRecord",
"name": "lifestory",
"contractTxId": "pFEB75N-TgJtCKWrCjgnPw84-3LB-HXLsSivHfIX1es",
"type": "lease",
"auction": false
},
"owner": "7leENbll3b2aU6bB9rOMLSGLbmWGkMym2Hyz4m_Et2k",
"valid": false,
"id": "7mQttmhoB4xEuaUX4paR12xgqlYo9Vxmpgk03wAvIUY"
}
dtfiedler commented 9 months ago

ah yes - that was it!

dtfiedler commented 9 months ago

we can merge this so when the fix to ar-io.dev is put in it'll update with it

dtfiedler commented 9 months ago

reference: https://ardrive.atlassian.net/browse/PE-5112