Skip to content

Commit

Permalink
Merge branch 'alpha' into sanchonet
Browse files Browse the repository at this point in the history
  • Loading branch information
rdlrt authored Nov 27, 2023
2 parents c991d74 + 30704c1 commit df5d14c
Show file tree
Hide file tree
Showing 12 changed files with 438 additions and 144 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/docker_bin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ name: Docker Image

on:
workflow_dispatch:
inputs:
guild_deploy_branch:
description: Branch to deploy
required: false
default: master
testing:
description: Testing workflow
required: false
type: boolean
default: false
push:
paths:
- 'files/docker/node/release-versions/cardano-node-latest.txt'
Expand All @@ -26,6 +36,7 @@ jobs:
--file files/docker/node/dockerfile_bin \
--compress \
--build-arg G_ACCOUNT=${{ env.G_ACCOUNT }} \
--build-arg GUILD_DEPLOY_BRANCH=${{ env.guild_deploy_branch }} \
--tag ${{ env.REGISTRY }}/${{ secrets.DOCKER_USER }}/cardano-node:latest
# Workaround to provide additional free space for builds.
# https://github.com/actions/virtual-environments/issues/2840
Expand All @@ -42,6 +53,7 @@ jobs:
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: docker push latest
if: env.testing == 'false' && env.guild_deploy_branch == 'master'
run: |
CNVERSION=`cat files/docker/node/release-versions/cardano-node-latest.txt`
docker push ${{ env.REGISTRY }}/${{ secrets.DOCKER_USER }}/cardano-node:latest
Expand Down
17 changes: 13 additions & 4 deletions docs/docker/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,19 @@ Running your own Cardano node has never been so fast and easy.
- cardano-hw-cli
- cardano-node
- cardano-submit-api
- mithril-client
- mithril-signer

#### Mithril

### 🔔 Built-in tools

- CNTools
- gLiveView
- CNCLI
- Ogmios
- Cardano Hardware CLI
- Cardano Signer
- Monitoring ready (with EKG and Prometheus)

#### Docker Splash screen
Expand All @@ -48,11 +55,13 @@ Running your own Cardano node has never been so fast and easy.

Modular docker images based on Debian.

Based on the Guild's work we decided to build the Cardano Node images in 3 stages:
Based on the Guild's work the Cardano Node image is built in a single stage: -> [dockerfile_bin](https://github.com/cardano-community/guild-operators/blob/master/files/docker/node/dockerfile_bin)

- Uses `guild-deploy.sh` to:
- Install the os prerequisites
- Add the cardano software from release binaries
- Add the guild's SPO tools and the node's configuration files.

- 1st stage: it uses `prereq.sh` to prepare the development environment before compiling the node source code. -> [Stage1](https://github.com/cardano-community/guild-operators/blob/master/files/docker/node/dockerfile_stage1)
- 2nd stage: based on stage1, this stage intent is to compile and produce the binaries of the node. -> [Stage2](https://github.com/cardano-community/guild-operators/blob/master/files/docker/node/dockerfile_stage2)
- 3rd stage: based upon a minimal debian image it incorporates the node's binaries as well as all the Koios' SPO tools. -> [Stage3](https://github.com/cardano-community/guild-operators/blob/master/files/docker/node/dockerfile_stage3)

### Additional docs

Expand Down
3 changes: 2 additions & 1 deletion docs/docker/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@
!!! info "Note"
1) `--entrypoint=bash` # This option won't start the node's container but only the OS running (the node software wont actually start, you'll need to manually execute entrypoint.sh ), ready to get in (trough the command ``` docker exec -it < container name or hash > /bin/bash ```) and play/explore around with it in command line mode.
2) all guild tools env variable can be used to start a new container using custom values by using the "-e" option.
3) CPU and RAM and SHared Memory allocation option for the container can be used when you start the container (i.e. --shm-size or --memory or --cpus [official docker resource docs](https://docs.docker.com/config/containers/resource_constraints/))
3) CPU and RAM and Shared Memory allocation option for the container can be used when you start the container (i.e. --shm-size or --memory or --cpus [official docker resource docs](https://docs.docker.com/config/containers/resource_constraints/))
4) `--env MITHRIL_DOWNLOAD=Y` # This option will allow Mithril client to download the latest Mithril snapshot of the blockchain when the container starts and does not have a copy of the blockchain yet. This is useful when you want to start a new node from scratch and don't want to wait for the node to sync from the network. This option is only available for the mainnet, preprod, and preview networks.
25 changes: 14 additions & 11 deletions files/docker/node/dockerfile_bin
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ STOPSIGNAL SIGINT
LABEL desc="Cardano Node by Guild's Operators"
ARG DEBIAN_FRONTEND=noninteractive
ARG G_ACCOUNT
ARG GUILD_DEPLOY_BRANCH

USER root
WORKDIR /
Expand Down Expand Up @@ -45,7 +46,7 @@ RUN set -x && apt update \
&& export SUDO='N' \
&& export UPDATE_CHECK='N' \
&& export SKIP_DBSYNC_DOWNLOAD='Y' \
&& chmod +x ./guild-deploy.sh && ./guild-deploy.sh -b master -s p \
&& chmod +x ./guild-deploy.sh && ./guild-deploy.sh -b ${GUILD_DEPLOY_BRANCH} -s p \
&& ls /opt/ \
&& mkdir -p $CNODE_HOME/priv/files \
&& apt-get -y remove libpq-dev build-essential pkg-config libffi-dev libgmp-dev libssl-dev libtinfo-dev libsystemd-dev zlib1g-dev make g++ \
Expand All @@ -58,14 +59,13 @@ RUN set -x && apt update \
RUN set -x && export SUDO='N' \
&& export UPDATE_CHECK='N' \
&& export SKIP_DBSYNC_DOWNLOAD='Y' \
&& ./guild-deploy.sh -b master -s dcowx \
&& ./guild-deploy.sh -b ${GUILD_DEPLOY_BRANCH} -s dcmowx \
&& cd /usr/bin \
&& wget http://www.vdberg.org/~richard/tcpping \
&& chmod 755 tcpping \
&& chown -R guild:guild $CNODE_HOME/* \
&& chown -R guild:guild $CNODE_HOME \
&& mv /root/.local/bin /home/guild/.local/ \
&& chown -R guild:guild /home/guild/.* \
&& chmod a+x /home/guild/.scripts/*.sh /opt/cardano/cnode/scripts/*.sh
&& chown -R guild:guild /home/guild/.*

# Add final tools in a separate layer to shrink the largest layer
RUN apt-get update \
Expand All @@ -89,15 +89,18 @@ RUN curl -sL -H "Accept: application/vnd.github.everest-preview+json" -H "Conte


# ENTRY SCRIPT
ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/banner.txt /home/guild/.scripts/
ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/guild-topology.sh /home/guild/.scripts/
ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/block_watcher.sh /home/guild/.scripts/
ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/healthcheck.sh /home/guild/.scripts/
ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/scripts/cnode-helper-scripts/guild-deploy.sh /opt/cardano/cnode/scripts/
ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/banner.txt \
https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/guild-topology.sh \
https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/block_watcher.sh \
https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/healthcheck.sh /home/guild/.scripts/
ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/scripts/cnode-helper-scripts/guild-deploy.sh \
https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/scripts/cnode-helper-scripts/mithril-client.sh \
https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/scripts/cnode-helper-scripts/mithril-signer.sh \
https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/scripts/cnode-helper-scripts/mithril-relay.sh /opt/cardano/cnode/scripts/
ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/entrypoint.sh ./

RUN sudo chmod a+rx /home/guild/.scripts/*.sh /opt/cardano/cnode/scripts/*.sh /home/guild/entrypoint.sh \
&& sudo chown -R guild:guild /home/guild/.* $CNODE_HOME/*
&& sudo chown -R guild:guild /home/guild/.* $CNODE_HOME

HEALTHCHECK --start-period=5m --interval=5m --timeout=100s CMD /home/guild/.scripts/healthcheck.sh

Expand Down
29 changes: 2 additions & 27 deletions scripts/cnode-helper-scripts/cntools.library
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ CNTOOLS_MAJOR_VERSION=11
# Minor: Changes and features of minor character that can be applied without breaking existing functionality or workflow
CNTOOLS_MINOR_VERSION=0
# Patch: Backwards compatible bug fixes. No additional functionality or major changes
CNTOOLS_PATCH_VERSION=2
CNTOOLS_PATCH_VERSION=3

CNTOOLS_VERSION="${CNTOOLS_MAJOR_VERSION}.${CNTOOLS_MINOR_VERSION}.${CNTOOLS_PATCH_VERSION}"

Expand Down Expand Up @@ -841,31 +841,6 @@ verifyTx() {
return 0
}

# Command : getPoolID [pool name]
# Description : create and save pool id in hex & bech32 encoded format
# Parameters : pool name > the name of the pool
# Return : populates ${pool_id} & ${pool_id_bech32}
getPoolID() {
pool_id_file="${POOL_FOLDER}/${1}/${POOL_ID_FILENAME}"
pool_id_bech32_file="${POOL_FOLDER}/${1}/${POOL_ID_FILENAME}-bech32"
[[ -f ${pool_id_file} && -f ${pool_id_bech32_file} ]] && pool_id=$(cat ${pool_id_file}) && pool_id_bech32=$(cat ${pool_id_bech32_file}) && return 0
pool_id=""
pool_id_bech32=""
pool_coldkey_vk_file="${POOL_FOLDER}/${1}/${POOL_COLDKEY_VK_FILENAME}"
if [[ -f ${pool_coldkey_vk_file} ]]; then
println ACTION "${CCLI} stake-pool id --cold-verification-key-file ${pool_coldkey_vk_file} --output-format hex"
println ACTION "${CCLI} stake-pool id --cold-verification-key-file ${pool_coldkey_vk_file}"
if ! pool_id=$(${CCLI} stake-pool id --cold-verification-key-file "${pool_coldkey_vk_file}" --output-format hex 2>/dev/null) || \
! pool_id_bech32=$(${CCLI} stake-pool id --cold-verification-key-file "${pool_coldkey_vk_file}" 2>/dev/null); then
return 1
fi
echo ${pool_id} > "${pool_id_file}"
echo ${pool_id_bech32} > "${pool_id_bech32_file}"
return 0
fi
return 1
}

# Command : getPayAddress [wallet name]
# Description : create and save payment address
# Parameters : wallet name > the name of the wallet
Expand Down Expand Up @@ -2081,7 +2056,7 @@ deRegisterPool() {
rotatePoolKeys() {

# cold keys
if getPoolType ${pool_name} ; then needHWCLI="true" ;fi
if getPoolType ${pool_name}; then needHWCLI="true"; else needHWCLI="false" ;fi

# generated files
pool_hotkey_vk_file="${POOL_FOLDER}/${pool_name}/${POOL_HOTKEY_VK_FILENAME}"
Expand Down
40 changes: 40 additions & 0 deletions scripts/cnode-helper-scripts/env
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,20 @@ timeLeft() {
printf '%02d:%02d:%02d' $H $M $S
}
# Description : Format number in compact format, ie thousand = k, millon = m etc, with variable precision
# Return : populates ${cn_value} & ${cn_suffix}
compactNumber() {
unset cn_value cn_suffix
if [[ $# -ne 1 ]] || ! isNumber $1; then return 1; fi
if [[ $1 -gt 100000000 ]]; then LC_NUMERIC=C printf -v cn_value "%.0f" "$(echo "$1/1000000" | bc -l)"; cn_suffix=M; return; fi
if [[ $1 -gt 10000000 ]]; then LC_NUMERIC=C printf -v cn_value "%.1f" "$(echo "$1/1000000" | bc -l)"; cn_suffix=M; return; fi
if [[ $1 -gt 1000000 ]]; then LC_NUMERIC=C printf -v cn_value "%.2f" "$(echo "$1/1000000" | bc -l)"; cn_suffix=M; return; fi
if [[ $1 -gt 100000 ]]; then LC_NUMERIC=C printf -v cn_value "%.0f" "$(echo "$1/1000" | bc -l)"; cn_suffix=k; return; fi
if [[ $1 -gt 10000 ]]; then LC_NUMERIC=C printf -v cn_value "%.1f" "$(echo "$1/1000" | bc -l)"; cn_suffix=k; return; fi
if [[ $1 -gt 1000 ]]; then LC_NUMERIC=C printf -v cn_value "%.2f" "$(echo "$1/1000" | bc -l)"; cn_suffix=k; return; fi
cn_value=$1
}
# Description : Get calculated slot number tip
getSlotTipRef() {
current_time_sec=$(printf '%(%s)T\n' -1)
Expand Down Expand Up @@ -699,6 +713,32 @@ kesExpiration() {
printf -v kes_expiration '%(%F %T %Z)T' ${expiration_time_sec}
}
# Description : create and save pool id in hex & bech32 encoded format
# Parameters : pool name > the name of the pool
# Return : populates ${pool_id} & ${pool_id_bech32}
getPoolID() {
local pool_dir
[[ -z "${1}" ]] && pool_dir="${POOL_DIR}" || pool_dir="${POOL_FOLDER}/${1}"
pool_id_file="${pool_dir}/${POOL_ID_FILENAME}"
pool_id_bech32_file="${pool_dir}/${POOL_ID_FILENAME}-bech32"
[[ -f ${pool_id_file} && -f ${pool_id_bech32_file} ]] && pool_id=$(cat ${pool_id_file}) && pool_id_bech32=$(cat ${pool_id_bech32_file}) && return 0
pool_id=""
pool_id_bech32=""
pool_coldkey_vk_file="${pool_dir}/${POOL_COLDKEY_VK_FILENAME}"
if [[ -f ${pool_coldkey_vk_file} ]]; then
println ACTION "${CCLI} stake-pool id --cold-verification-key-file ${pool_coldkey_vk_file} --output-format hex"
println ACTION "${CCLI} stake-pool id --cold-verification-key-file ${pool_coldkey_vk_file}"
if ! pool_id=$(${CCLI} stake-pool id --cold-verification-key-file "${pool_coldkey_vk_file}" --output-format hex 2>/dev/null) || \
! pool_id_bech32=$(${CCLI} stake-pool id --cold-verification-key-file "${pool_coldkey_vk_file}" 2>/dev/null); then
return 1
fi
echo ${pool_id} > "${pool_id_file}"
echo ${pool_id_bech32} > "${pool_id_bech32_file}"
return 0
fi
return 1
}
# Description : Calculate expected interval between blocks
slotInterval() {
if [[ -z ${DECENTRALISATION} || $(echo "${DECENTRALISATION} < 0.5" | bc) -eq 1 ]]; then d=0.5; else d=${DECENTRALISATION}; fi
Expand Down
Loading

0 comments on commit df5d14c

Please sign in to comment.