Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue building graph-ql with Docker from a clean state #302

Closed
issoupadrink opened this issue Sep 15, 2020 · 6 comments
Closed

Issue building graph-ql with Docker from a clean state #302

issoupadrink opened this issue Sep 15, 2020 · 6 comments
Assignees
Labels

Comments

@issoupadrink
Copy link

I ran docker-compose up -d --build && docker-compose logs -f and got this error message:

FatalError: column delegation.pool_hash_id does not exist written by cardano-graphql.

This was on the latest tag (2.0.0-rc.0).

@issoupadrink
Copy link
Author

Full error message:

cardano-graphql_1           | GraphQL HTTP server at http://0.0.0.0:3100/ started
cardano-graphql_1           | {"level":"info","msg":"Applying migrations...","time":"2020-09-15T11:59:43Z"}
cardano-graphql_1           | 
cardano-graphql_1           | Command failed: hasura --skip-update-check --project /application/packages/api-cardano-db-hasura/hasura/project --endpoint http://hasura:8080 migrate apply --up all
cardano-graphql_1           | time="2020-09-15T11:59:43Z" level=fatal msg="apply failed: [postgres-error] query execution failed ($.args[0].args)\r\nFile: '1589369664961_init/up.sql'\r\n{\n    \"check_metadata_consistency\": false,\n    \"sql\": \"CREATE VIEW \\\"Block\\\" AS\\n SELECT (COALESCE(( SELECT sum((tx.fee)::bigint) AS sum\\n           FROM tx\\n          WHERE (tx.block = block.id)), (0)::NUMERIC))::bigint AS fees,\\n    block.hash,\\n    block.merkel_root AS \\\"merkelRoot\\\",\\n    block.block_no AS \\\"number\\\",\\n    block.op_cert AS \\\"opCert\\\",\\n    previous_block.hash AS \\\"previousBlockHash\\\",\\n    next_block.hash AS \\\"nextBlockHash\\\",\\n    block.proto_version AS \\\"protocolVersion\\\",\\n    block.size,\\n    block.tx_count AS \\\"transactionsCount\\\",\\n    block.epoch_no AS \\\"epochNo\\\",\\n    block.\\\"time\\\" AS \\\"forgedAt\\\",\\n    block.epoch_slot_no AS \\\"slotInEpoch\\\",\\n    block.slot_no AS \\\"slotNo\\\",\\n    slot_leader.id AS \\\"slot_leader_id\\\",\\n    block.vrf_key As \\\"vrfKey\\\"\\n   FROM (((block\\n     LEFT JOIN block previous_block ON ((block.previous = previous_block.id)))\\n     LEFT JOIN block next_block ON ((next_block.previous = block.id)))\\n     LEFT JOIN slot_leader ON ((block.slot_leader = slot_leader.id)));\\n\\nCREATE OR REPLACE VIEW \\\"Cardano\\\" AS\\n SELECT block.block_no AS \\\"tipBlockNo\\\",\\n    block.epoch_no AS \\\"currentEpochNo\\\"\\n   FROM block\\n  WHERE (block.block_no IS NOT NULL)\\n  ORDER BY block.block_no DESC\\n LIMIT 1;\\n \\nCREATE VIEW \\\"Delegation\\\" AS\\nSELECT\\n  delegation.id AS \\\"id\\\",\\n  (\\n\\t  SELECT stake_address.view\\n\\t  FROM stake_address\\n\\t  WHERE stake_address.id = delegation.addr_id\\n  ) AS \\\"address\\\",\\n  delegation.tx_id AS \\\"tx_id\\\",\\n  pool_hash.hash AS \\\"pool_hash\\\"\\nFROM\\n  delegation\\nLEFT OUTER JOIN pool_hash\\n  ON delegation.pool_hash_id = pool_hash.id;\\n\\nCREATE VIEW \\\"Epoch\\\" AS\\nSELECT\\n  epoch.out_sum AS \\\"output\\\",\\n  epoch.no AS \\\"number\\\",\\n  epoch.tx_count AS \\\"transactionsCount\\\",\\n  epoch.start_time AS \\\"startedAt\\\",\\n  epoch.end_time AS \\\"lastBlockTime\\\",\\n  epoch.blk_count AS \\\"blocksCount\\\"\\nFROM epoch;\\n\\nCREATE VIEW \\\"Reward\\\" AS\\nSELECT\\n  reward.amount AS \\\"amount\\\",\\n  reward.id AS \\\"id\\\",\\n  (\\n\\t  SELECT stake_address.view\\n\\t  FROM stake_address\\n\\t  WHERE stake_address.id = reward.addr_id\\n  ) AS \\\"address\\\",\\n  reward.tx_id AS \\\"tx_id\\\"\\nFROM reward;\\n\\nCREATE VIEW \\\"SlotLeader\\\" AS\\nSELECT\\n  slot_leader.hash AS \\\"hash\\\",\\n  slot_leader.id AS \\\"id\\\",\\n  slot_leader.description AS \\\"description\\\",\\n  ( SELECT pool_hash.hash FROM pool_hash WHERE pool_hash.id = slot_leader.pool_hash_id ) AS \\\"pool_hash\\\"\\nFROM slot_leader;\\n\\nCREATE VIEW \\\"StakeDeregistration\\\" AS\\nSELECT\\n  stake_deregistration.id AS \\\"id\\\",\\n  (\\n\\t  SELECT stake_address.view\\n\\t  FROM stake_address\\n\\t  WHERE stake_address.id = stake_deregistration.addr_id\\n  ) AS \\\"address\\\",\\n  stake_deregistration.tx_id AS \\\"tx_id\\\"\\nFROM stake_deregistration;\\n\\nCREATE VIEW \\\"StakePool\\\" AS\\nWITH\\n  latest_block_times AS (\\n    SELECT pool.hash_id, max(block.time) AS blockTime\\n    FROM pool_update AS pool\\n    JOIN tx ON pool.registered_tx_id = tx.id\\n    JOIN block ON tx.block = block.id\\n    group by pool.hash_id\\n)\\nSELECT\\n  pool.fixed_cost AS \\\"fixedCost\\\",\\n  ( SELECT pool_hash.hash FROM pool_hash WHERE pool_hash.id = pool.hash_id ) AS \\\"hash\\\",\\n  pool.id AS \\\"id\\\",\\n  pool.margin AS \\\"margin\\\",\\n  pool_meta_data.hash AS \\\"metadataHash\\\",\\n  block.block_no AS \\\"blockNo\\\",\\n  pool.registered_tx_id AS \\\"updated_in_tx_id\\\",\\n  pool.pledge AS \\\"pledge\\\",\\n  ( SELECT stake_address.view FROM stake_address WHERE stake_address.id = pool.reward_addr_id) AS \\\"rewardAddress\\\",\\n  pool_meta_data.url AS \\\"url\\\"\\nFROM pool_update AS pool\\n  INNER JOIN pool_meta_data ON pool.meta = pool_meta_data.id\\n  INNER JOIN tx ON pool.registered_tx_id = tx.id\\n  INNER JOIN latest_block_times ON latest_block_times.hash_id = pool.hash_id\\n  INNER JOIN block ON tx.block = block.id AND latest_block_times.blockTime = block.time;\\n\\nCREATE VIEW \\\"StakePoolRetirement\\\" AS\\nSELECT\\n  retiring_epoch as \\\"inEffectFrom\\\",\\n  announced_tx_id as \\\"tx_id\\\",\\n  ( SELECT pool_hash.hash FROM pool_hash WHERE pool_hash.id = hash_id ) AS \\\"pool_hash\\\"\\nFROM pool_retire;\\n\\nCREATE VIEW \\\"StakeRegistration\\\" AS\\nSELECT\\n  stake_registration.id AS \\\"id\\\",\\n  (\\n\\t  SELECT stake_address.view\\n\\t  FROM stake_address\\n\\t  WHERE stake_address.id = stake_registration.addr_id\\n  ) AS \\\"address\\\",\\n  stake_registration.tx_id AS \\\"tx_id\\\"\\nFROM stake_registration;\\n\\nCREATE VIEW \\\"Transaction\\\" AS\\nSELECT\\n  block.hash AS \\\"blockHash\\\",\\n  tx.block_index AS \\\"blockIndex\\\",\\n  COALESCE(tx.fee, 0) AS fee,\\n  tx.hash,\\n  tx.id,\\n  block.time AS \\\"includedAt\\\",\\n  tx.size,\\n  CAST(COALESCE((SELECT SUM(\\\"value\\\") FROM tx_out WHERE tx_id = tx.id), 0) AS bigint) AS \\\"totalOutput\\\"\\nFROM\\n  tx\\nINNER JOIN block\\n  ON block.id = tx.block;\\n\\nCREATE VIEW \\\"TransactionInput\\\" AS\\nSELECT\\n  source_tx_out.address,\\n  source_tx_out.value,\\n  tx.hash AS \\\"txHash\\\",\\n  source_tx.hash AS \\\"sourceTxHash\\\",\\n  tx_in.tx_out_index AS \\\"sourceTxIndex\\\"\\nFROM\\n  tx\\nJOIN tx_in\\n  ON tx_in.tx_in_id = tx.id\\nJOIN tx_out AS source_tx_out\\n  ON tx_in.tx_out_id = source_tx_out.tx_id\\n  AND tx_in.tx_out_index = source_tx_out.index\\nJOIN tx AS source_tx\\n  ON source_tx_out.tx_id = source_tx.id;\\n\\nCREATE VIEW \\\"TransactionOutput\\\" AS\\nSELECT\\n  address,\\n  value,\\n  tx.hash AS \\\"txHash\\\",\\n  index\\nFROM tx\\nJOIN tx_out\\n  ON tx.id = tx_out.tx_id;\\n\\nCREATE VIEW \\\"Utxo\\\" AS SELECT\\n  address,\\n  value,\\n  tx.hash AS \\\"txHash\\\",\\n  index\\nFROM tx\\nJOIN tx_out\\n  ON tx.id = tx_out.tx_id\\nLEFT OUTER JOIN tx_in\\n  ON tx_out.tx_id = tx_in.tx_out_id\\n  AND tx_out.index = tx_in.tx_out_index\\nWHERE tx_in.tx_in_id IS NULL;\\n\\nCREATE VIEW \\\"Withdrawal\\\" AS\\nSELECT\\n  withdrawal.amount AS \\\"amount\\\",\\n  withdrawal.id AS \\\"id\\\",\\n  (\\n\\t  SELECT stake_address.view\\n\\t  FROM stake_address\\n\\t  WHERE stake_address.id = withdrawal.addr_id\\n  ) AS \\\"address\\\",\\n  withdrawal.tx_id AS \\\"tx_id\\\"\\nFROM withdrawal;\\n\\nCREATE INDEX idx_block_hash\\n    ON block(hash);\\n\\nCREATE INDEX idx_tx_hash\\n    ON tx(hash);\\n\\n CREATE INDEX idx_tx_in_consuming_tx\\n    ON tx_in(tx_out_id);\\n\\nCREATE INDEX idx_tx_out_tx\\n    ON tx_out(tx_id);\\n\\nCREATE function utxo_set_at_block(\\\"hash\\\" hash32type)\\nRETURNS SETOF \\\"TransactionOutput\\\" AS $$\\n  SELECT\\n    \\\"TransactionOutput\\\".address,\\n    \\\"TransactionOutput\\\".value,\\n    \\\"TransactionOutput\\\".\\\"txHash\\\",\\n    \\\"TransactionOutput\\\".index\\n  FROM tx\\n  JOIN tx_out\\n    ON tx.id = tx_out.tx_id\\n  JOIN \\\"TransactionOutput\\\"\\n    ON tx.hash = \\\"TransactionOutput\\\".\\\"txHash\\\"\\n  LEFT OUTER JOIN tx_in\\n    ON tx_out.tx_id = tx_in.tx_out_id\\n    AND tx_out.index = tx_in.tx_out_index\\n  WHERE tx_in.tx_in_id IS NULL\\n  AND tx.block \\u003c= (SELECT id FROM block WHERE hash = \\\"hash\\\")\\n$$ LANGUAGE SQL stable;\\n\\n\"\n}\r\n[42703] FatalError: column delegation.pool_hash_id does not exist"

@disassembler
Copy link
Contributor

Can you share your docker-compose file you're using? 2.0.0 is only compatible with 3.x of db-sync. We're working on getting a new release for graphql/explorer that integrates with db-sync 5.0.0.

@danielimkk
Copy link

Hello @disassembler! Do you have any estimated time of releasing new version of cardano-graphql and db-sync 5.0.0?

I've tried to build graphql from master and use it with 5.0.0 db-sync, now it seems to not fail anymore, but queries can be sent only through hasura, while on graphql previous calls return this message: "Error: Query root type must be provided."

Would be highly appreciated to get some news or help on fixing that little issue

@rhyslbw
Copy link
Contributor

rhyslbw commented Sep 16, 2020

@danielimkk The new versions are in the final stages of the release process now, so very soon. Did you rebuild the DB after upgrading to 5.0.0?

@danielimkk
Copy link

@rhyslbw Awesome news! I did start a completely new node. Everything seems fine, except the queries are not passed :)

Not sure what could cause this error, but here is an example of query that works for hasura, but returns errors on graphql:

query MyQuery {
  cardano {
    tip {
      number
    }
  }
}

Response for Hasura:

{
  "data": {
    "cardano": [
      {
        "tip": {
          "number": 207366
        }
      }
    ]
  }
}

Response for GraphQl:

{
  "errors": [
    {
      "message": "Error: Query root type must be provided.",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "cardano"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "stacktrace": [
            "Error: Error: Query root type must be provided.",
            "    at Object.<anonymous> (/application/packages/api-cardano-db-hasura/dist/executableSchema.js:78:35)",
            "    at Generator.next (<anonymous>)",
            "    at /application/packages/api-cardano-db-hasura/dist/executableSchema.js:8:71",
            "    at new Promise (<anonymous>)",
            "    at __awaiter (/application/packages/api-cardano-db-hasura/dist/executableSchema.js:4:12)",
            "    at cardano (/application/packages/api-cardano-db-hasura/dist/executableSchema.js:63:63)",
            "    at field.resolve (/application/node_modules/graphql-extensions/dist/index.js:134:26)",
            "    at field.resolve (/application/node_modules/apollo-server-core/dist/utils/schemaInstrumentation.js:52:26)",
            "    at resolveFieldValueOrError (/application/node_modules/graphql/execution/execute.js:467:18)",
            "    at resolveField (/application/node_modules/graphql/execution/execute.js:434:16)"
          ]
        }
      }
    }
  ],
  "data": null
}

Hopefully this information can be helpful

By the way seems like current master branch has no query for rewards. Is that query in the roadmap?

Thank you!

@rhyslbw
Copy link
Contributor

rhyslbw commented Sep 16, 2020

@issoupadrink I suspect you have an older master image on your docker host. The release process means I don't have a tag to target up until the last moment, so the master tag is specified as a stand-in.

@danielimkk I'll assist further when the new version is out, as I can't reproduce this specifically. Duplicate of #281 There's no need to drop the node data since it takes quite a while to resync. Regarding this rewards, follow IntersectMBO/cardano-db-sync#198 for updates on when rewards will be in the db.

@rhyslbw rhyslbw closed this as completed Sep 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants