From df07dc2034628011e2e778b8a185faff97042464 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Placzy=C5=84ski?= Date: Fri, 16 Feb 2024 06:55:59 +0100 Subject: [PATCH] Revert "[#181] Implement hotfix for SanchoNet Cardano DB Sync configuration issue" This reverts commit b55a3a91df8712c33446ae8e049328d754964889. There is a solution made for https://github.com/IntersectMBO/cardano-db-sync/issues/1629 involving a new image release. The new image is ghcr.io/intersectmbo/cardano-db-sync:sancho-4-0-0-fix-config. We will use the official solution instead of my hotfix, hence this revert. We also want to document our efforts that's why we do not simply romowe the reverted commit from the history. --- scripts/govtool/dbsync/govtool-dbsync | 72 ----------------- scripts/govtool/dbsync/govtool-entrypoint | 81 -------------------- scripts/govtool/dbsync/govtool-sanchonet | 3 - scripts/govtool/docker-compose.sanchonet.yml | 4 - scripts/govtool/prepare-config.sh | 7 -- 5 files changed, 167 deletions(-) delete mode 100755 scripts/govtool/dbsync/govtool-dbsync delete mode 100755 scripts/govtool/dbsync/govtool-entrypoint delete mode 100755 scripts/govtool/dbsync/govtool-sanchonet diff --git a/scripts/govtool/dbsync/govtool-dbsync b/scripts/govtool/dbsync/govtool-dbsync deleted file mode 100755 index ce914684e..000000000 --- a/scripts/govtool/dbsync/govtool-dbsync +++ /dev/null @@ -1,72 +0,0 @@ -#!/nix/store/vqvj60h076bhqj6977caz0pfxs6543nb-bash-5.2-p15/bin/bash -set -euo pipefail - -export CARDANO_NODE_SOCKET_PATH="/node-ipc/node.socket" - - - - - -if [ ! -z "${RESTORE_SNAPSHOT:-}" ]; then -SNAPSHOT_BASENAME="$(basename "$RESTORE_SNAPSHOT")" -RESTORED_MARKER="$SNAPSHOT_BASENAME.restored" -if [ ! -f "$RESTORED_MARKER" ]; then - if [[ "$RESTORE_SNAPSHOT" =~ ^https://.* ]]; then - echo "Downloading snapshot $RESTORE_SNAPSHOT ..." - /nix/store/6g6s5cqbvk1nw2y2c8lpbn95sk0w24f9-curl-8.2.1-bin/bin/curl -LOC - "$RESTORE_SNAPSHOT" - - /nix/store/6g6s5cqbvk1nw2y2c8lpbn95sk0w24f9-curl-8.2.1-bin/bin/curl -LO "$RESTORE_SNAPSHOT.sha256sum" - /nix/store/apn3p2b40xvirn7w740wv2gy330ppib5-coreutils-9.3/bin/sha256sum -c "$SNAPSHOT_BASENAME.sha256sum" - - - - SNAPSHOT="$SNAPSHOT_BASENAME" - else - SNAPSHOT="$RESTORE_SNAPSHOT" - fi - rm -f /var/lib/cexplorer/*.lstate - /nix/store/1bys3yjgm97yxy91sfy8f5law41fyif9-postgresql-setup.sh --restore-snapshot "$SNAPSHOT" /var/lib/cexplorer - touch $RESTORED_MARKER - rm -f $SNAPSHOT{,.sha256sum,.asc} -fi -fi - - -if [[ -n "${WAIT_FOR_NODE_SYNC:-}" ]] -then - until [ -S $CARDANO_NODE_SOCKET_PATH ]; do - echo Waiting for $CARDANO_NODE_SOCKET_PATH - sleep 10 - done - # from scripts/postgresql-setup.sh - export PGHOST=$(cut -d ":" -f 1 "${PGPASSFILE}") - export PGPORT=$(cut -d ":" -f 2 "${PGPASSFILE}") - export PGDATABASE=$(cut -d ":" -f 3 "${PGPASSFILE}") - user=$(cut -d ":" -f 4 "${PGPASSFILE}") - if [ "$user" != "*" ]; then - export PGUSER=$user - fi; - DB_MAX_BLOCK=$(psql -h $PGHOST $PGDATABASE -U $PGUSER -t -c 'select max (block_no) from block;') - NODE_CUR_BLOCK=0 - while [ $NODE_CUR_BLOCK -lt $DB_MAX_BLOCK ]; do - NODE_STATUS="$(cardano-cli query tip --testnet-magic $(jq '.networkMagic' /nix/store/558hxsvn739289w35s5nhy8p89iispb4-shelley-genesis.json) 2>/dev/null || true)" - NODE_CUR_BLOCK="$(jq -e -r '.block' <<<"$NODE_STATUS" 2>/dev/null || true)" - echo "Waiting... Sync progress at $NODE_CUR_BLOCK /$DB_MAX_BLOCK" - sleep 10 - done -fi - -mkdir -p log-dir -if [[ "${DISABLE_LEDGER:-N}" == "Y" ]]; then - LEDGER_OPTS="--disable-ledger" -else - LEDGER_OPTS="--state-dir /var/lib/cexplorer" -fi - -exec /nix/store/hjlmcj93mxvl1wqfsmac1pj9rfk106hw-cardano-db-sync-exe-cardano-db-sync-13.2.0.0/bin/cardano-db-sync \ - --config /configuration/db-sync-config.json \ - --socket-path "$CARDANO_NODE_SOCKET_PATH" \ - --schema-dir /nix/store/4xzm921ryfrvp73j86alrq8rkk14h7s6-schema \ - ${LEDGER_OPTS} \ - ${EXTRA_DB_SYNC_ARGS:-} - diff --git a/scripts/govtool/dbsync/govtool-entrypoint b/scripts/govtool/dbsync/govtool-entrypoint deleted file mode 100755 index acd578f06..000000000 --- a/scripts/govtool/dbsync/govtool-entrypoint +++ /dev/null @@ -1,81 +0,0 @@ -#!/nix/store/vqvj60h076bhqj6977caz0pfxs6543nb-bash-5.2-p15/bin/bash -mkdir -p /configuration -if [ ! -f /configuration/pgpass ]; then - /nix/store/vwp2kcwif9afpcqpm31bxlk9gh3h2r5r-gen-pgpass /run/secrets -fi -export PGPASSFILE=/configuration/pgpass - -# set up /tmp (override with TMPDIR variable) -mkdir -p -m 1777 /tmp -if [[ -z "$NETWORK" ]]; then - echo "Connecting to network specified in configuration.yaml" - DBSYNC=/nix/store/hjlmcj93mxvl1wqfsmac1pj9rfk106hw-cardano-db-sync-exe-cardano-db-sync-13.2.0.0/bin/cardano-db-sync - - set -euo pipefail - if [ ! -z "${RESTORE_SNAPSHOT:-}" ]; then -SNAPSHOT_BASENAME="$(basename "$RESTORE_SNAPSHOT")" -RESTORED_MARKER="$SNAPSHOT_BASENAME.restored" -if [ ! -f "$RESTORED_MARKER" ]; then - if [[ "$RESTORE_SNAPSHOT" =~ ^https://.* ]]; then - echo "Downloading snapshot $RESTORE_SNAPSHOT ..." - /nix/store/6g6s5cqbvk1nw2y2c8lpbn95sk0w24f9-curl-8.2.1-bin/bin/curl -LOC - "$RESTORE_SNAPSHOT" - - /nix/store/6g6s5cqbvk1nw2y2c8lpbn95sk0w24f9-curl-8.2.1-bin/bin/curl -LO "$RESTORE_SNAPSHOT.sha256sum" - /nix/store/apn3p2b40xvirn7w740wv2gy330ppib5-coreutils-9.3/bin/sha256sum -c "$SNAPSHOT_BASENAME.sha256sum" - - - - SNAPSHOT="$SNAPSHOT_BASENAME" - else - SNAPSHOT="$RESTORE_SNAPSHOT" - fi - rm -f /var/lib/cexplorer/*.lstate - /nix/store/1bys3yjgm97yxy91sfy8f5law41fyif9-postgresql-setup.sh --restore-snapshot "$SNAPSHOT" /var/lib/cexplorer - touch $RESTORED_MARKER - rm -f $SNAPSHOT{,.sha256sum,.asc} -fi -fi - - - if [[ "${DISABLE_LEDGER:-N}" == "Y" ]]; then - LEDGER_OPTS="--disable-ledger" - else - LEDGER_OPTS="--state-dir /var/lib/cexplorer" - fi - - exec $DBSYNC --schema-dir /nix/store/4xzm921ryfrvp73j86alrq8rkk14h7s6-schema ${LEDGER_OPTS} $@ - -elif [[ "$NETWORK" == "mainnet" ]]; then - echo "Connecting to network: mainnet" - exec /nix/store/85v1wxvwsf487ng3pc0cfw999jzgyf00-cardano-db-sync-mainnet/bin/cardano-db-sync-mainnet - echo "Cleaning up" - -elif [[ "$NETWORK" == "preprod" ]]; then - echo "Connecting to network: preprod" - exec /nix/store/3qmpvpl9p1azinz2aqp4rgmhfymn7m2y-cardano-db-sync-preprod/bin/cardano-db-sync-preprod - echo "Cleaning up" - -elif [[ "$NETWORK" == "preview" ]]; then - echo "Connecting to network: preview" - exec /nix/store/km8zmilk90kb51q1qg4vf8d72dwb3w7l-cardano-db-sync-preview/bin/cardano-db-sync-preview - echo "Cleaning up" - -elif [[ "$NETWORK" == "private" ]]; then - echo "Connecting to network: private" - exec /nix/store/674zfi0nxjxbzmi9lbjm6pfdgdxhnvv2-cardano-db-sync-private/bin/cardano-db-sync-private - echo "Cleaning up" - -elif [[ "$NETWORK" == "sanchonet" ]]; then - echo "Connecting to network: sanchonet" - exec /scripts/govtool-sanchonet - echo "Cleaning up" - -elif [[ "$NETWORK" == "shelley_qa" ]]; then - echo "Connecting to network: shelley_qa" - exec /nix/store/2dv0dff02yx5cixxiacp2ha70z53hhc3-cardano-db-sync-shelley_qa/bin/cardano-db-sync-shelley_qa - echo "Cleaning up" - - -else - echo "Managed configuration for network "$NETWORK" does not exist" -fi diff --git a/scripts/govtool/dbsync/govtool-sanchonet b/scripts/govtool/dbsync/govtool-sanchonet deleted file mode 100755 index 8612cad47..000000000 --- a/scripts/govtool/dbsync/govtool-sanchonet +++ /dev/null @@ -1,3 +0,0 @@ -#!/nix/store/vqvj60h076bhqj6977caz0pfxs6543nb-bash-5.2-p15/bin/bash -set -euo pipefail -/scripts/govtool-dbsync $@ diff --git a/scripts/govtool/docker-compose.sanchonet.yml b/scripts/govtool/docker-compose.sanchonet.yml index 7278acddf..5c052a02d 100644 --- a/scripts/govtool/docker-compose.sanchonet.yml +++ b/scripts/govtool/docker-compose.sanchonet.yml @@ -160,13 +160,9 @@ services: - postgres_password - postgres_user - postgres_db - entrypoint: - - /scripts/govtool-entrypoint volumes: - db-sync-data:/var/lib/cexplorer - node-ipc:/node-ipc - - /home/ubuntu/config/cardano-node:/configuration - - /home/ubuntu/config/dbsync-scripts:/scripts restart: always logging: *logging diff --git a/scripts/govtool/prepare-config.sh b/scripts/govtool/prepare-config.sh index 9be21ebf3..062a1ecaf 100755 --- a/scripts/govtool/prepare-config.sh +++ b/scripts/govtool/prepare-config.sh @@ -7,13 +7,6 @@ config_dir="$repo_root_dir/scripts/govtool/config" target_config_dir="$repo_root_dir/scripts/govtool/config/target" mkdir -p "$target_config_dir" -# prepare a scripts directory for the DBSync entrypoint -dbsync_scripts_dir="$target_config_dir/dbsync-scripts" -mkdir -p "$dbsync_scripts_dir" -cp "$repo_root_dir/scripts/govtool/dbsync/govtool-entrypoint" "$dbsync_scripts_dir/govtool-entrypoint" -cp "$repo_root_dir/scripts/govtool/dbsync/govtool-sanchonet" "$dbsync_scripts_dir/govtool-sanchonet" -cp "$repo_root_dir/scripts/govtool/dbsync/govtool-dbsync" "$dbsync_scripts_dir/govtool-dbsync" - # cardano node config cardano_node_config_dir="$target_config_dir/cardano-node" mkdir -p "$cardano_node_config_dir"