fudgebucket27 / Lexplorer

Loopring explorer alternative
14 stars 10 forks source link

hosted services on thegraph are being sunsetted eventually #50

Open fudgebucket27 opened 2 years ago

fudgebucket27 commented 2 years ago

we need to consider creating our on subgraph that does not rely on the hosted service

fudgebucket27 commented 2 years ago

repo for non hosted service subgraph is at https://github.com/fudgebucket27/lexplorerSubgraph

fudgebucket27 commented 2 years ago

ive deployed a decentralized subgraph here https://thegraph.com/explorer/subgraph?id=7uEwnMS2iUNS2dqFMKSWnAA5ghe2fUCNUcYfwXpNc4eP&view=Overview i think we should switch eventually

modersohn commented 2 years ago

Wow this looks cool - does that mean we could even extent the protocol? Like add the missing connection between pool and token I mentioned in #63?

We could surely test the new graph URL on dev - can't this set depending on the environment, i.e. deployment vs. dev?

AFAICS this hosting is not free, right? The more we query, the more you're gonna pay. I mean that's a whole different topic, but cost/monetization is something you definitely should think about long term....

fudgebucket27 commented 2 years ago

Yeh I'd be interested to see performance of the subgraph on the Dev site. Yes there are query fees but its not that bad I think. Yep we could modify the graph to our needs too.

fudgebucket27 commented 2 years ago

looks like official explorer is switching to a decentralized network: https://github.com/Loopring/loopring-explorer/pull/24/commits/0373bc0e3352e4d83fcc7f0b794787eb93078000 @modersohn

modersohn commented 2 years ago

We could switch to just the same, right? But technically, right now it's identical to the deployed subgraph you already made, correct?

fudgebucket27 commented 2 years ago

Yes we should switch to the same subgraph they are using. I tried the subgraph I deployed but getting transactions didn't work at all unfortunately.

modersohn commented 2 years ago

I tried the subgraph I deployed but getting transactions didn't work at all unfortunately.

Can you be more specific? Did the actual queries fail, i.e. do they fail on the playground too?

fudgebucket27 commented 2 years ago

It seems to happen on both subgraphs Here is the baseurl for the new one loopring made: https://gateway.thegraph.com/api/1aa6e776d0018868067a8ab36b0255a8/subgraphs/id/HgnaENC2oG5hJFsWoHvULBbj7djTJ7TZnqa58iTWA3Rd

The response returned from the GetTransactions method in the GraphQLService class is this ""{}"\"errors\":{\"message\":\"Invalid query\". Doesn't look like we have unit test for that either.

I see this is on the homepage and in the transactions page.

modersohn commented 2 years ago

OK I added a test and that fails with the same error using your baseURL. If I paste that query into the playground it shows a mismatch error for token and feeToken in various fragments. It says it's a mismatch between Token and Token!.

FWIW, here's the (massive!) query, if you wanna try:

              query transactions(
                $skip: Int
                $first: Int
                $orderBy: Transaction_orderBy
                $orderDirection: OrderDirection
                $block: Block_height
                $where: Transaction_filter
              ) {
                proxy(id: 0) {
                  transactionCount
                  depositCount
                  withdrawalCount
                  transferCount
                  addCount
                  removeCount
                  orderbookTradeCount
                  swapCount
                  accountUpdateCount
                  ammUpdateCount
                  signatureVerificationCount
                  tradeNFTCount
                  swapNFTCount
                  withdrawalNFTCount
                  transferNFTCount
                  nftMintCount
                  nftDataCount
                }
                transactions(
                  skip: $skip
                  first: $first
                  orderBy: $orderBy
                  orderDirection: $orderDirection
                  block: $block
                  where: $where
                ) {
                  id
                  internalID
                  block {
                    id
                    blockHash
                    timestamp
                    transactionCount
                    depositCount
                    withdrawalCount
                    transferCount
                    addCount
                    removeCount
                    orderbookTradeCount
                    swapCount
                    accountUpdateCount
                    ammUpdateCount
                    signatureVerificationCount
                    tradeNFTCount
                    swapNFTCount
                    withdrawalNFTCount
                    transferNFTCount
                    nftMintCount
                    nftDataCount
                  }
                  data
                  ...AddFragment
                  ...RemoveFragment
                  ...SwapFragment
                  ...OrderbookTradeFragment
                  ...DepositFragment
                  ...WithdrawalFragment
                  ...TransferFragment
                  ...AccountUpdateFragment
                  ...AmmUpdateFragment
                  ...SignatureVerificationFragment
                  ...TradeNFTFragment
                  ...SwapNFTFragment
                  ...WithdrawalNFTFragment
                  ...TransferNFTFragment
                  ...MintNFTFragment
                  ...DataNFTFragment
                }
              }
            fragment AccountFragment on Account {
                id
                address
                __typename
            }
            fragment TokenFragment on Token {
                id
                name
                symbol
                decimals
                address
              }
            fragment PoolFragment on Pool {
                id
                address
                __typename
                createdAtTransaction {
                  ...AccountCreatedAtFragment
                }
                feeBipsAMM
              }
            fragment AccountCreatedAtFragment on Transaction {
                id
                __typename
                block {
                  id
                  timestamp
                }
            }
          fragment NFTFragment on NonFungibleToken {
            id
            minter {
              ...AccountFragment
            }
            __typename
            nftID
            nftType
            token
          }

        fragment AddFragment on Add {
            id
            account {
              ...AccountFragment
            }
            pool {
              ...PoolFragment
            }
            token {
              ...TokenFragment
            }
            feeToken {
              ...TokenFragment
            }
            amount
            fee
            __typename
          }
         fragment RemoveFragment on Remove {
            id
            account {
              ...AccountFragment
            }
            pool {
              ...PoolFragment
            }
            token {
              ...TokenFragment
            }
            feeToken {
              ...TokenFragment
            }
            amount
            fee
            __typename
          }
        fragment SwapFragment on Swap {
            id
            account {
              ...AccountFragment
            }
            pool {
              ...PoolFragment
            }
            tokenA {
              ...TokenFragment
            }
            tokenB {
              ...TokenFragment
            }
            pair {
              id
              token0 {
                symbol
              }
              token1 {
                symbol
              }
            }
            tokenAPrice
            tokenBPrice
            fillSA
            fillSB
            fillBA
            fillBB
            protocolFeeA
            protocolFeeB
            feeA
            feeB
            __typename
          }
          fragment OrderbookTradeFragment on OrderbookTrade {
            id
            accountA {
              ...AccountFragment
            }
            accountB {
              ...AccountFragment
            }
            tokenA {
              ...TokenFragment
            }
            tokenB {
              ...TokenFragment
            }
            pair {
              id
              token0 {
                symbol
              }
              token1 {
                symbol
              }
            }
            tokenAPrice
            tokenBPrice
            fillSA
            fillSB
            fillBA
            fillBB
            fillAmountBorSA
            fillAmountBorSB
            feeA
            feeB
            __typename
          }
          fragment DepositFragment on Deposit {
            id
            toAccount {
              ...AccountFragment
            }
            token {
              ...TokenFragment
            }
            amount
            __typename
          }
          fragment WithdrawalFragment on Withdrawal {
            id
            fromAccount {
              ...AccountFragment
            }
            token {
              ...TokenFragment
            }
            feeToken {
              ...TokenFragment
            }
            amount
            fee
            __typename
          }
         fragment TransferFragment on Transfer {
            id
            fromAccount {
              ...AccountFragment
            }
            toAccount {
              ...AccountFragment
            }
            token {
              ...TokenFragment
            }
            feeToken {
              ...TokenFragment
            }
            amount
            fee
            __typename
          }
          fragment AccountUpdateFragment on AccountUpdate {
            id
            user {
              id
              address
              publicKey
            }
            feeToken {
              ...TokenFragment
            }
            fee
            nonce
            __typename
          }
          fragment AmmUpdateFragment on AmmUpdate {
            id
            pool {
              ...PoolFragment
            }
            tokenID
            feeBips
            tokenWeight
            nonce
            balance
            __typename
          }
          fragment SignatureVerificationFragment on SignatureVerification {
            id
            account {
              ...AccountFragment
            }
            verificationData
            __typename
          }
          fragment TradeNFTFragment on TradeNFT {
            id
            accountSeller {
              ...AccountFragment
            }
            accountBuyer {
              ...AccountFragment
            }
            token {
              ...TokenFragment
            }
            nfts {
              ...NFTFragment
            }
            realizedNFTPrice
            feeBuyer
            feeSeller
            fillSA
            fillBA
            fillSB
            fillBB
            protocolFeeBuyer
            __typename
          }
         fragment SwapNFTFragment on SwapNFT {
            id
            accountA {
              ...AccountFragment
            }
            accountB {
              ...AccountFragment
            }
            nfts {
              ...NFTFragment
            }
            __typename
          }
          fragment WithdrawalNFTFragment on WithdrawalNFT {
            id
            fromAccount {
              ...AccountFragment
            }
            fee
            feeToken {
              ...TokenFragment
            }
            nfts {
              ...NFTFragment
            }
            amount
            valid
            __typename
          }
          fragment TransferNFTFragment on TransferNFT {
            id
            fromAccount {
              ...AccountFragment
            }
            toAccount {
              ...AccountFragment
            }
            feeToken {
              ...TokenFragment
            }
            nfts {
              ...NFTFragment
            }
            fee
            amount
            __typename
          }
          fragment MintNFTFragment on MintNFT {
            id
            minter {
              ...AccountFragment
            }
            receiver {
              ...AccountFragment
            }
            receiverSlot {
              id
            }
            nft {
              ...NFTFragment
            }
            fee
            feeToken {
              ...TokenFragment
            }
            amount
            __typename
          }
        fragment DataNFTFragment on DataNFT {
            __typename
          }
fudgebucket27 commented 2 years ago

I'll have to do some research to help try and resolve this then

modersohn commented 2 years ago

OK, I found the reason: we always define the query parameters block and where but only provide them if they're non-null. If I remove these two, the new test succeeds.

Still leaves me puzzled why the hosted graph would be fine, but doesn't really matter.

I'll make a PR for an updated query and the missing test (might take until tomorrow) - then you can do your tests with the other graphs.