0

I am following the following guide to set up graphql on my M1 Mac. https://github.com/input-output-hk/cardano-graphql#overview. All the containers are up and running but i can't visit local host to play around with graphql.The containers i am running have a amd64 warning error. Is there a way to get past this warning ? Has anyone else been able to setup cardano-graphql on M1 Mac?

1 Answer 1

1

Took me like 6+ Months to figure out all the requirements and what modules need to get loaded first...

This guide helped a lot https://robferguson.org/blog/2022/02/19/getting-started-with-cardano-graphql/ And he coverers building on mac.

These steps assume you have a docker GraphQL git environment already created and volumes ending in *_db-sync-data and *_postgres-data are empty. If you are tring to sync DB-Sync then remove Postgres and db-sync-data volumes. Ogmios data will be fine.

If you have data in *_db-sync-data and *_postgres-data, please remove the data. We need a fresh state for all of this to work. See https://github.com/input-output-hk/cardano-graphql/wiki/Docker#rebuild-cardano-db for help. (If you use CGQL only select postgres)

1st

Start Ogmios and let it sync up to 80-99% depending on what snapshot you download (I suggest waiting until its at least 95% synced).

`Docker-compose up -d` then `Docker-compose down` finally
`docker-compose start cardano-node-ogmios`

This will only start Ogmios, wait a day or until you are at 70-90%.

2nd

Now we need to sync cardano-db-sync-extended. Go to the IOHK snapshot https://update-cardano-mainnet.iohk.io/cardano-db-sync/index.html#13/ (PS we are in folder 13/ right now, but look in 12/ folder for older snapshots) and choose the latest snapshot (if Ogmios is synced to 95%) or an older snapshot from folder 12/ if you are synced below 95%.

NOTE choosing a snapshot that is before that current sync point of Ogmios is fine, but getting a snapshot that is past Ogmios sync point will cause DB-Sync to delete any blocks past Ogmios sync point and can take a bit longer to delete then re-sync.

Syncing without a snapshot can take 3+ Days, I tried once and Ogmios was fully synced it took DB-sync 3 days to only get to ~70% and I have SSDs.

If you look at the Ogmios logs you should see one saying what slot & block it is currently at: [3d54f2c4:cardano.node.ChainDB:Notice:2262] [2022-06-05 16:59:45.33 UTC] Chain extended, new tip: b57fbffcfccc13b56f0f869bf0b1dc699c4b020217ff9292d3504f56b83448bf at slot 62882094 {"severity":"Info","timestamp":"2022-06-05T16:59:45.341328986Z","thread":"3454","message":{"Health":{"tag":"HealthTick","status":{"startTime":"2022-06-04T13:55:56.922570134Z","lastKnownTip":{"slot":62882094,"hash":"b57fbffcfccc13b56f0f869bf0b1dc699c4b020217ff9292d3504f56b83448bf","blockNo":7337678},"lastTipUpdate":"2022-06-05T16:59:45.341113964Z","networkSynchronization":1.00000,"currentEra":"Alonzo","metrics":{"sessionDurations":{"max":0,"min":0,"mean":244854.64556962025},"totalMessages":6957619,"runtimeStats":{"currentHeapSize":2551,"maxHeapSize":10242,"gcCpuTime":522927267999,"cpuTime":5356749610627},"activeConnections":5,"totalUnrouted":0,"totalConnections":84},"connectionStatus":"connected","currentEpoch":343,"slotInEpoch":69294}}},"version":"v5.1.0"} Which shows I am at Block: 7337678 and Blockchain Slot: 62882094 So I know I use the latest release "db-sync-snapshot-schema-13-block-7334319-x86_64.tgz" since 7337678 > 7334319.

Now we need to start DB-Sync:

There are 2 ways to do this.

One way is to let db-sync download the file from IOHK but there is a chance that the download can become interrupted and will not finish or continue after. (easiest but may not work..)

The other way is to manually download the snapshot and edit docker-compose.yml to have DB-sync load it from a local file instead of downloading(suggested)

Way 1 - not-recommended

export NETWORK=mainnet &&\ RESTORE_SNAPSHOT=https://update-cardano-mainnet.iohk.io/cardano-db-sync/12/db-sync-snapshot-schema-12-block-6764999-x86_64.tgz \ docker-compose up -d &&\ docker-compose logs -f Insert your snapshot link instead of mine.

Then wait ~2 hours and the download should be down and the system should start adding/altering tables in the DB-sync log.

If you see messages saying download was interrupted or stopped and it can not resume. Then try Way 2 and delete volumes *_postgres-data and .

https://github.com/input-output-hk/cardano-graphql/wiki/Docker#rebuild-cardano-db for help on removing volumes

Way 2 - Recommended

Navigate to container folder, then create a "snapshots" directory and give it access to all users (777).

Now we download the snapshot to "snapshots" using wget: wget https://update-cardano-mainnet.iohk.io/cardano-db-sync/13/db-sync-snapshot-schema-13-block-7334319-x86_64.tgz

Next, we need to edit docker-compose.yml, look for "cardano-db-sync-extended" then the volumes should look like this:

   volumes:
    - ./config/network/${NETWORK:-mainnet}:/config
    - db-sync-data:/var/lib/cdbsync
    - node-ipc:/node-ipc
    - db-sync-tmp:/tmp
    - ./snapshots:/snapshots

Finally at the bottom of Docker-compose.yml, look for and edit the Volumes array. It should look like this:

volumes:
  db-sync-data:
  node-db:
  node-ipc:
  postgres-data:
  db-sync-tmp:

Now we can start DB Sync and Postgres

export NETWORK=mainnet && \ export RESTORE_SNAPSHOT=/snapshots/*FILE_NAME* && \ docker-compose up -d

which will start Postgres, Hasura, DB-Sync, GraphQL and Ogmios (if not already running).

Let DB Sync run for a day or so then it should be down unpacking. If you see anything saying that DB-sync is rolling back to genesis and the amount of block to be deleted is >2-5K then your snapshot was too far ahead and you need to wait for DB-sync to delete all those Blocks, before it uses to Hasura to continue syncing.

At this point, it might be worth it to restart the DB-sync process with older snapshot, But it is hard to say how long the deletion will take and depends on your system setup. If it is more than 5-10K of blocks that need to be deleted then I say re-start the DB-sync process with a older snapshot, or close DB-sync and wait for Ogmios to sync more.

GraphQL may come up with a fresh install after running the docker-compose up command from Github, but db-sync never fully syncs so it is never usable for me.

After DB-sync is done, if GraphQL port is still not online then restart the GraphQL module only and wait a day. docker-compose restart cardano-graphql

the GraphQL port and interface should come up after 1-3 hrs after DB Sync is fully synced and Ogmios is around 99-100%

Errors I saw

`psql:/tmp/db-sync-snapshot-hc6bN9lE7U/db-sync-snapshot-schema-12-block-6451499-x86_64.sql:238416086: ERROR: could not extend file "base/16384/214298": No space left on device HINT: Check free disk space.

psql:/tmp/db-sync-snapshot-hc6bN9lE7U/db-sync-snapshot-schema-12-block-6451499-x86_64.sql:238416150: ERROR: could not write block 35045 of temporary file: No space left on device CONTEXT: parallel worker`

https://robferguson.org/blog/2022/02/19/getting-started-with-cardano-graphql/

Be carful using docker image prune since it could delete your Ogmios data and add an extra day or two to the whole sync process. But normally the Check Free disk Space error is because the system can not unzip the snapshot because of space limitations.

Even if you should have enough space, I found that sometimes I needed to delete all my volumes to get it to work.

Background

Ive been trying to get GraphQL to work for months now... I've tried on a few different servers over the months, but I just recently have been able to get it online.

Also make sure your system has the requirement to run the full stack (32GB Ram needed and SSDs strongly encouraged): https://github.com/input-output-hk/cardano-graphql/releases

Hope this helps and saves people some months like me XD

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.