Skip to content

Commit

Permalink
Move dbscripts SQL to koios-artifacts repo, and prep v1.1.0 (#1708)
Browse files Browse the repository at this point in the history
## Description
<!--- Describe your changes -->
- [x] Move /scripts/gnode-helper-scripts/dbscripts folder to
koios-artifacts repo (v1.1.0 tag), as it only contains SQL files.
Accordingly update setup-grest.sh references.
- [x] Some left-over hard-coded entries (other than documentation ones)
for `cardano-community` replaced by `${G_ACCOUNT}`
- [x] Update dbsync.sh to also pre-fill conway genesis hash
- [x] Install cron job for asset_txo_cache_update
- [x] Bump setup-grest.sh tag reference to v1.1.0

## How has this been tested?
<!--- Describe how you tested changes -->
Tested on v1 instance
  • Loading branch information
rdlrt authored Nov 27, 2023
1 parent 30704c1 commit a147fc1
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 221 deletions.
6 changes: 4 additions & 2 deletions scripts/cnode-helper-scripts/dbsync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ check_config_sanity() {
SHGENHASHCFG=$(jq '.ShelleyGenesisHash' <"${CONFIG}" 2>/dev/null)
ALGENHASH=$("${CCLI}" genesis hash --genesis "${ALONZO_GENESIS_JSON}" 2>/dev/null)
ALGENHASHCFG=$(jq '.AlonzoGenesisHash' <"${CONFIG}" 2>/dev/null)
CWGENHASH=$("${CCLI}" genesis hash --genesis "${CONWAY_GENESIS_JSON}" 2>/dev/null)
CWGENHASHCFG=$(jq '.ConwayGenesisHash' <"${CONFIG}" 2>/dev/null)
# If hash are missing/do not match, add that to the end of config. We could have sorted it based on logic, but that would mess up sdiff comparison outputs
if [[ "${BYGENHASH}" != "${BYGENHASHCFG}" ]] || [[ "${SHGENHASH}" != "${SHGENHASHCFG}" ]] || [[ "${ALGENHASH}" != "${ALGENHASHCFG}" ]]; then
if [[ "${BYGENHASH}" != "${BYGENHASHCFG}" ]] || [[ "${SHGENHASH}" != "${SHGENHASHCFG}" ]] || [[ "${ALGENHASH}" != "${ALGENHASHCFG}" ]] || [[ "${CWGENHASH}" != "${CWGENHASHCFG}" ]]; then
cp "${CONFIG}" "${CONFIG}".tmp
jq --arg BYGENHASH ${BYGENHASH} --arg SHGENHASH ${SHGENHASH} --arg ALGENHASH ${ALGENHASH} '.ByronGenesisHash = $BYGENHASH | .ShelleyGenesisHash = $SHGENHASH | .AlonzoGenesisHash = $ALGENHASH' <"${CONFIG}" >"${CONFIG}".tmp
jq --arg BYGENHASH ${BYGENHASH} --arg SHGENHASH ${SHGENHASH} --arg ALGENHASH ${ALGENHASH} --arg CWGENHASH ${CWGENHASH} '.ByronGenesisHash = $BYGENHASH | .ShelleyGenesisHash = $SHGENHASH | .AlonzoGenesisHash = $ALGENHASH | .ConwayGenesisHash = $CWGENHASH' <"${CONFIG}" >"${CONFIG}".tmp
[[ -s "${CONFIG}".tmp ]] && mv -f "${CONFIG}".tmp "${CONFIG}"
fi
}
Expand Down
1 change: 0 additions & 1 deletion scripts/cnode-helper-scripts/env
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,6 @@ set_default_vars() {
[[ -z ${G_ACCOUNT} ]] && G_ACCOUNT="cardano-community"
URL_RAW="https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/${BRANCH}"
DB_SCRIPTS_URL="${URL_RAW}/scripts/grest-helper-scripts/db-scripts"
export LC_ALL=C.UTF-8
# special mapping of coreutils gdate to date for MacOS
if [[ $(uname) == Darwin ]]; then
Expand Down
2 changes: 1 addition & 1 deletion scripts/cnode-helper-scripts/gLiveView.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ if [[ ${UPDATE_CHECK} = Y && ${SKIP_UPDATE} != Y ]]; then

if command -v cncli >/dev/null && command -v systemctl >/dev/null && systemctl is-active --quiet ${CNODE_VNAME}-cncli-sync.service; then
vcur=$(cncli -V | sed 's/cncli /v/g')
vrem=$(curl -s https://api.github.com/repos/cardano-community/cncli/releases/latest | jq -r .tag_name)
vrem=$(curl -s https://api.github.com/repos/${G_ACCOUNT}/cncli/releases/latest | jq -r .tag_name)
[[ ${vcur} != ${vrem} ]] && printf "${FG_MAGENTA}CNCLI current version (${vcur}) different from repo (${vrem}), consider upgrading!.${NC}" && waitToProceed
fi

Expand Down
4 changes: 2 additions & 2 deletions scripts/cnode-helper-scripts/guild-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,11 @@ download_cncli() {
[[ -z ${ARCH##*aarch64*} ]] && err_exit " The cncli pre-compiled binary is not available for ARM, you might need to build them!"
echo -e "\nInstalling CNCLI.."
if command -v cncli >/dev/null; then cncli_version="v$(cncli -V 2>/dev/null | cut -d' ' -f2)"; else cncli_version="v0.0.0"; fi
cncli_git_version="$(curl -s https://api.github.com/repos/cardano-community/cncli/releases/latest | jq -r '.tag_name')"
cncli_git_version="$(curl -s https://api.github.com/repos/${G_ACCOUNT}/cncli/releases/latest | jq -r '.tag_name')"
echo -e "\n Downloading CNCLI..."
rm -rf /tmp/cncli-bin && mkdir /tmp/cncli-bin
pushd /tmp/cncli-bin >/dev/null || err_exit
cncli_asset_url="$(curl -s https://api.github.com/repos/cardano-community/cncli/releases/latest | jq -r '.assets[].browser_download_url' | grep 'linux-musl.tar.gz')"
cncli_asset_url="$(curl -s https://api.github.com/repos/${G_ACCOUNT}/cncli/releases/latest | jq -r '.assets[].browser_download_url' | grep 'linux-musl.tar.gz')"
if curl -sL -f -m ${CURL_TIMEOUT} -o cncli.tar.gz ${cncli_asset_url}; then
tar zxf cncli.tar.gz &>/dev/null
rm -f cncli.tar.gz
Expand Down
173 changes: 0 additions & 173 deletions scripts/grest-helper-scripts/db-scripts/basics.sql

This file was deleted.

18 changes: 0 additions & 18 deletions scripts/grest-helper-scripts/db-scripts/genesis_table.sql

This file was deleted.

21 changes: 0 additions & 21 deletions scripts/grest-helper-scripts/db-scripts/reset_grest.sql

This file was deleted.

11 changes: 8 additions & 3 deletions scripts/grest-helper-scripts/setup-grest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# Do NOT modify code below #
######################################

SGVERSION=v1.1.0rc
SGVERSION=v1.1.0

######## Functions ########
usage() {
Expand Down Expand Up @@ -91,7 +91,7 @@ SGVERSION=v1.1.0rc
get_cron_job_executable() {
local job=$1
local job_path="${CRON_SCRIPTS_DIR}/${job}.sh"
local job_url="https://raw.githubusercontent.com/cardano-community/koios-artifacts/${SGVERSION}/files/grest/cron/jobs/${job}.sh"
local job_url="https://raw.githubusercontent.com/${G_ACCOUNT}/koios-artifacts/${SGVERSION}/files/grest/cron/jobs/${job}.sh"
if curl -s -f -m "${CURL_TIMEOUT}" -o "${job_path}" "${job_url}"; then
printf "\n Downloaded \e[32m${job_path}\e[0m"
chmod +x "${job_path}"
Expand Down Expand Up @@ -172,7 +172,11 @@ SGVERSION=v1.1.0rc

get_cron_job_executable "asset-info-cache-update"
set_cron_variables "asset-info-cache-update"
install_cron_job "asset-info-cache-update" "* * * * *"
install_cron_job "asset-info-cache-update" "*/2 * * * *"

get_cron_job_executable "asset-txo-cache-update"
set_cron_variables "asset-txo-cache-update"
install_cron_job "asset-txo-cache-update" "*/5 * * * *"

get_cron_job_executable "epoch-summary-corrections-update"
set_cron_variables "epoch-summary-corrections-update"
Expand Down Expand Up @@ -205,6 +209,7 @@ SGVERSION=v1.1.0rc
[[ -z "${CRON_DIR}" ]] && CRON_DIR="/etc/cron.d"
[[ -z "${PGDATABASE}" ]] && PGDATABASE="cexplorer"
[[ -z "${HAPROXY_CFG}" ]] && HAPROXY_CFG="${CNODE_HOME}/files/haproxy.cfg"
[[ -z "${DB_SCRIPTS_URL}" ]] && DB_SCRIPTS_URL="https://raw.githubusercontent.com/${G_ACCOUNT}/koios-artifacts/${SGVERSION}/files/grest/rpc/db-scripts"
DOCS_URL="https://cardano-community.github.io/guild-operators"
[[ -z "${PGPASSFILE}" ]] && export PGPASSFILE="${CNODE_HOME}"/priv/.pgpass
case ${NWMAGIC} in
Expand Down

0 comments on commit a147fc1

Please sign in to comment.