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

chore: build the Haskell parts with haskell.nix #537

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

michalrus
Copy link

Description

We discovered with @rhyslbw that the current master no longer builds (fails on Haskell compilation), so the build process is not very reproducible.

Proposed Solution

Let’s reuse the 100% reproducible build definitions signed off by the cardano-node team. For both cardano-node, and cardano-db-sync.

Node’s build process is too complicated and fragile, and it's very hard to reproduce it reliably here. We can just use their definitions, which work, and are used in official releases.

We also have an option to disable the IOG binary cache, and build the world from source (see a comment added inside the Dockerfile).

Important Changes Introduced

The external interface doesn’t change.

Testing

The external interface doesn’t change.

Copy link
Collaborator

@rhyslbw rhyslbw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @michalrus 🦾

It would be better to make the binary cache opt-in behind a Docker build arg, to better align with the Rosetta spec intent.

@michalrus michalrus force-pushed the build-with-haskelldotnix branch from 2ce9fe5 to 0e71213 Compare October 3, 2023 10:54
@michalrus
Copy link
Author

michalrus commented Oct 3, 2023

Okay, I think I made everything work now (including ARM builds! 🍎):

❯ docker top cardano-rosetta
UID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD
102                 24931               24913               1                   13:19               pts/0               00:00:00            node /usr/bin/pm2-runtime start ecosystem.config.js --env production
102                 25070               24931               0                   13:19               ?                   00:00:00            /usr/lib/postgresql/12/bin/postgres -D /data/postgresql -c config_file=/etc/postgresql/12/main/postgresql.conf
102                 25071               24931               52                  13:19               ?                   00:00:07            /opt/cardano-node/lib/ld-linux-x86-64.so.2 /opt/cardano-node/exe/cardano-node run --config /config/cardano-node/config.json --database-path /data/node-db --socket-path /ipc/node.socket --topology /config/cardano-node/topology.json
102                 25082               24931               29                  13:19               ?                   00:00:04            /opt/cardano-db-sync/lib/ld-linux-x86-64.so.2 /opt/cardano-db-sync/exe/cardano-db-sync --config /config/cardano-db-sync/config.json --schema-dir /cardano-db-sync/schema/ --socket-path /ipc/node.socket --state-dir /data/db-sync
102                 25084               24931               18                  13:19               ?                   00:00:02            node /cardano-rosetta-server/dist/src/server/index.js
102                 25092               25070               0                   13:19               ?                   00:00:00            postgres: 12/main: checkpointer
102                 25093               25070               0                   13:19               ?                   00:00:00            postgres: 12/main: background writer
102                 25094               25070               0                   13:19               ?                   00:00:00            postgres: 12/main: walwriter
102                 25095               25070               0                   13:19               ?                   00:00:00            postgres: 12/main: autovacuum launcher
102                 25096               25070               0                   13:19               ?                   00:00:00            postgres: 12/main: stats collector
102                 25097               25070               0                   13:19               ?                   00:00:00            postgres: 12/main: logical replication launcher
102                 25509               25070               24                  13:19               ?                   00:00:00            postgres: 12/main: postgres cexplorer [local] idle

stdout/stderr:

Cardano Rosetta
Initializing DB
Starting
2023-10-03T11:19:19: PM2 log: Launching in no daemon mode
2023-10-03T11:19:19: PM2 log: App [postgres:0] starting in -fork mode-
2023-10-03T11:19:19: PM2 log: App [postgres:0] online
2023-10-03T11:19:19: PM2 log: App [cardano-node:1] starting in -fork mode-
2023-10-03T11:19:19: PM2 log: App [cardano-node:1] online
2023-10-03T11:19:19: PM2 log: App [cardano-db-sync:2] starting in -fork mode-
2023-10-03T11:19:19: PM2 log: App [cardano-db-sync:2] online
2023-10-03T11:19:19: PM2 log: App [cardano-rosetta-server:3] starting in -fork mode-
2023-10-03T11:19:19: PM2 log: App [cardano-rosetta-server:3] online

[…]

[559f2da7:cardano.node.ChainDB:Notice:36] [2023-10-03 11:19:43.37 UTC] Chain extended, new tip: 6c9c08b1ee251b60104b15c075e76f464ae6222359899ca24f894be9994c9397 at slot 9701
[db-sync-node:Info:68] [2023-10-03 11:19:43.77 UTC] Took a ledger snapshot at /data/db-sync/9998-5afa460d82.lstate. It took 0.004161365s.
[db-sync-node:Info:68] [2023-10-03 11:19:43.77 UTC] insertByronBlock: epoch 0, slot 9999, block 10000, hash e6a510ff8ae57fdc1c9d66692fbf32502e00e3f88ad94471f0c851b5ec5eb847
[559f2da7:cardano.node.ChainDB:Notice:36] [2023-10-03 11:19:45.56 UTC] Chain extended, new tip: 5193c28c91ce814b5cf85df25bb621a146adf7582290c72adeb853ac5f1ec41f at slot 10402

[…]

@@ -178,26 +132,28 @@ COPY cardano-rosetta-server/package.json \
cardano-rosetta-server/yarn.lock \
cardano-rosetta-server/.yarnrc \
/app/
RUN chmod -R g+rX,o+rX /app
Copy link
Author

@michalrus michalrus Oct 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These chmods are necessary in case the user running docker build has umask 0077 on the repository source

ENV PGPASSFILE=/config/cardano-db-sync/pgpass
RUN echo "/var/run/postgresql:5432:cexplorer:*:*" > $PGPASSFILE &&\
RUN echo "/var/run/postgresql:5432:cexplorer:postgres:*" > $PGPASSFILE &&\
Copy link
Author

@michalrus michalrus Oct 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -17,8 +17,9 @@ module.exports = {
},
{
name: 'cardano-node',
script: '/usr/local/bin/cardano-node',
script: '/bin/sh',
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s no longer an ELF, so PM2 can’t recognize it correctly (if it’s not an ELF, it assumes it’s JavaScript)

@michalrus
Copy link
Author

It would be better to make the binary cache opt-in behind a Docker build arg, to better align with the Rosetta spec intent.

Fixed in 3eb8d5b.

@michalrus michalrus requested a review from rhyslbw October 3, 2023 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants