Skip to content

feat: testnet w/ cardano-node 10.4.1 and dingo 0.12.0 #20

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions compose/Dockerfile.dingo
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
ARG CARDANO_CLI_VERSION="${CARDANO_CLI_VERSION:-10.8.0.0}"
ARG CARDANO_NODE_VERSION="${CARDANO_NODE_VERSION:-10.4.1}"
ARG DINGO_VERSION="${DINGO_VERSION:-0.12.0}"
ARG UV_VERSION="${UV_VERSION:-0.6.11}"
# Blink Labs images are built from source on Debian Bookworm
FROM ghcr.io/blinklabs-io/cardano-cli:${CARDANO_CLI_VERSION} AS cardano-cli
FROM ghcr.io/astral-sh/uv:${UV_VERSION} AS uv

FROM ghcr.io/blinklabs-io/cardano-node:${CARDANO_NODE_VERSION} AS build

# Set time zone
ENV TZ="UTC"
RUN ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime && \
echo ${TZ} > /etc/timezone

# Install packages required in build stage
RUN apt update && \
apt install -y --no-install-recommends \
ca-certificates \
curl \
git \
tar

# Copy cardano-cli from image
COPY --from=cardano-cli --chown=root:root /usr/local/bin/cardano-cli /usr/local/bin/cardano-cli
# Copy uv from image
COPY --from=uv --chown=root:root /uv /usr/local/bin/uv

# Create cardano-node source directory
RUN install --directory --owner=root --group=root --mode=0755 /usr/local/src/cardano-node

# Clone testnet-generation-tool.git repository
WORKDIR /usr/local/src
RUN git clone --branch main https://github.com/cardano-foundation/testnet-generation-tool.git

# Download testnet-generation-tool dependencies
WORKDIR /usr/local/src/testnet-generation-tool
RUN uv sync

# Copy testnet.yaml specification
COPY --chown=root:root .testnet.yaml /usr/local/src/testnet-generation-tool/testnet.yaml

# Build testnet configuration files
RUN uv run python3 genesis-cli.py testnet.yaml -o /tmp/testnet -c generate

# Remove dynamic topology.json
RUN find /tmp/testnet -type f -name 'topology.json' -exec rm -f '{}' ';'

# Delete ftsSeed (dingo requires a string, currently)
RUN find /tmp/testnet -type f -name 'byron-genesis.json' -exec sed -i '/ftsSeed/d' '{}' ';'

#---------------------------------------------------------------------

FROM ghcr.io/blinklabs-io/dingo:${DINGO_VERSION}

# Set time zone
ENV TZ="UTC"
RUN ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime && \
echo ${TZ} > /etc/timezone

# Install packages required in main stage
RUN apt update && \
apt install -y --no-install-recommends \
dnsutils \
iproute2 \
iputils-ping \
jq \
less \
lsof \
netbase \
netcat-openbsd \
openssl \
procps \
tcpdump \
telnet \
vim

# Create cardano group and user
RUN groupadd --gid 10000 cardano && \
useradd --comment 'cardano' --create-home --gid 10000 --password '!' --shell '/bin/bash' --uid 10000 cardano

# Create cardano-node directories
RUN install --directory --owner=root --group=root --mode=0755 /opt/cardano-node && \
install --directory --owner=cardano --group=cardano --mode=0750 /opt/cardano-node/config && \
install --directory --owner=cardano --group=cardano --mode=0750 /opt/cardano-node/data && \
install --directory --owner=cardano --group=cardano --mode=0750 /opt/cardano-node/data/db && \
install --directory --owner=cardano --group=cardano --mode=0750 /opt/cardano-node/log && \
install --directory --owner=cardano --group=cardano --mode=0750 /opt/cardano-node/pools

# Copy pool config and key material
COPY --from=build --chown=cardano:cardano /tmp/testnet/pools /opt/cardano-node/pools

# Copy dingo.sh
COPY dingo.sh /
RUN chmod 0755 /dingo.sh

USER cardano
#STOPSIGNAL SIGINT

ENTRYPOINT ["/dingo.sh"]
12 changes: 9 additions & 3 deletions compose/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ help:
@echo " make anti password='password1234' session_id=<some session_id> input_hash=<some hash> vtime=<decimal seconds>"
@echo

build: TESTNET build-image build-config build-sidecar build-tracer build-tracer-sidecar ## Build cardano-node, config, sidecar, and tracer images
build: TESTNET build-image build-config build-sidecar build-tracer build-tracer-sidecar build-dingo ## Build cardano-node, config, sidecar, and tracer images

build-image: TESTNET ## Build cardano-node container image
ln -snf testnets/${testnet}/testnet.yaml .testnet.yaml ; cd testnets/${testnet} ; docker compose build
Expand All @@ -65,7 +65,10 @@ build-tracer: TESTNET ## Build tracer container image
build-tracer-sidecar: TESTNET ## Build tracer container image
docker build -f tracer-sidecar/Dockerfile -t ${registry}${testnet}_tracer-sidecar:latest tracer-sidecar/

push: TESTNET push-image push-config push-tracer push-sidecar push-tracer-sidecar ## Push cardano-node, config and sidecar container image
build-dingo: TESTNET ## Build dingo container image
docker build -f Dockerfile.dingo -t ${registry}${testnet}_dingo:latest .

push: TESTNET push-image push-config push-tracer push-sidecar push-tracer-sidecar push-dingo ## Push cardano-node, config and sidecar container image

push-image: TESTNET ## Push cardano-node container image
docker push ${registry}${testnet}:latest
Expand All @@ -82,6 +85,9 @@ push-tracer: TESTNET ## Push tracer container image
push-tracer-sidecar: TESTNET ## Push tracer container image
docker push ${registry}${testnet}_tracer-sidecar:latest

push-dingo: TESTNET ## Push dingo container image
docker push ${registry}${testnet}_dingo:latest

up: TESTNET ## Start Run local Docker Compose
cd testnets/${testnet} ; docker compose up --detach

Expand All @@ -100,7 +106,7 @@ anti: TESTNET ## Run Antithesis job
--arg description '${description}' \
--arg duration '${duration}' \
--arg config_image '${testnet}_config:latest' \
--arg images '${testnet}:latest;${testnet}_sidecar:latest;${testnet}_tracer:latest;${testnet}_tracer-sidecar:latest' \
--arg images '${testnet}:latest;${testnet}_sidecar:latest;${testnet}_tracer:latest;${testnet}_tracer-sidecar:latest;${testnet}_dingo:latest' \
--arg recipients '${recipients}' \
'{params: {"antithesis.description": $$description,"custom.duration": $$duration,"antithesis.config_image": $$config_image,"antithesis.images": $$images,"antithesis.report.recipients": $$recipients}}')"

Expand Down
129 changes: 129 additions & 0 deletions compose/dingo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
#!/usr/bin/env bash

# Required for overriding exit code
#set -o errexit
set -o pipefail

SHELL="/bin/bash"
PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin"

# Environment variables
PORT="${PORT:-3001}"
PROMETHEUS_LISTEN="${PROMETHEUS_LISTEN:-127.0.0.1}"
PROMETHEUS_PORT="${PROMETHEUS_PORT:-12798}"
SYSTEM_START="${SYSTEM_START:-$(date -d "@$(( ( $(date +%s) / 120 ) * 120 ))" +%Y-%m-%dT%H:%M:00Z)}"
USE_LEDGER_AFTER_SLOT="${USE_LEDGER_AFTER_SLOT:-0}"

# Antithesis
ANTITHESIS_OUTPUT_DIR="${ANTITHESIS_OUTPUT_DIR:-/tmp}"

# Configuration files
BYRON_GENESIS_JSON="${BYRON_GENESIS_JSON:-/opt/cardano-node/pools/1/configs/byron-genesis.json}"
CARDANO_CONFIG="/opt/cardano-node/pools/1/configs/config.json"
CONFIG_PATH="/opt/cardano-node/config"
DATA_PATH="/opt/cardano-node/data"
SHELLEY_GENESIS_JSON="${SHELLEY_GENESIS_JSON:-/opt/cardano-node/pools/1/configs/shelley-genesis.json}"

# Log file
LOG_FILE="/opt/cardano-node/log/node.json"

# Implement sponge-like command without the need for binary nor TMPDIR environment variable
write_file() {
# Create temporary file
local tmp_file="${1}_$(tr </dev/urandom -dc A-Za-z0-9 | head -c16)"

# Redirect the output to the temporary file
cat >"${tmp_file}"

# Replace the original file
mv --force "${tmp_file}" "${1}"
}

config_config_json() {
# .AlonzoGenesisHash, .ByronGenesisHash, .ConwayGenesisHash, .ShelleyGenesisHash
jq "del(.AlonzoGenesisHash, .ByronGenesisHash, .ConwayGenesisHash, .ShelleyGenesisHash)" "${CARDANO_CONFIG}" | write_file "${CARDANO_CONFIG}"

# .PeerSharing
if [ "${PEER_SHARING,,}" = "true" ]; then
jq ".PeerSharing = true" "${CARDANO_CONFIG}" | write_file "${CARDANO_CONFIG}"
else
jq ".PeerSharing = false" "${CARDANO_CONFIG}" | write_file "${CARDANO_CONFIG}"
fi
}

config_topology_json() {
# Connect to everything
mkdir -p ${CONFIG_PATH}
cat <<EOF > "${CONFIG_PATH}/topology-dingo.json"
{
"localRoots": [
{
"accessPoints": [
{"address": "p1.example", "port": 3001},
{"address": "p2.example", "port": 3001},
{"address": "p3.example", "port": 3001},
{"address": "p4.example", "port": 3001},
{"address": "p5.example", "port": 3001}
],
"advertise": true,
"trustable": true,
"valency": 2
}
],
"publicRoots": [],
"useLedgerAfterSlot": 0
}
EOF
}

set_start_time() {
if [ ! -f "${DATA_PATH}/start_time.unix_epoch" ]; then
# Convert ISO time to unix epoch
SYSTEM_START_UNIX=$(date -d "${SYSTEM_START}" +%s)
mkdir -p ${DATA_PATH}
echo "${SYSTEM_START_UNIX}" >"${DATA_PATH}/start_time.unix_epoch"

update_start_time
else
SYSTEM_START_UNIX="$(cat "${DATA_PATH}/start_time.unix_epoch")"
update_start_time
fi
}

update_start_time() {
# Convert unix epoch to ISO time
SYSTEM_START_ISO="$(date -d @${SYSTEM_START_UNIX} '+%Y-%m-%dT%H:%M:00Z')"

# .systemStart
jq ".systemStart = \"${SYSTEM_START_ISO}\"" "${SHELLEY_GENESIS_JSON}" | write_file "${SHELLEY_GENESIS_JSON}"

# .startTime
jq ".startTime = ${SYSTEM_START_UNIX}" "${BYRON_GENESIS_JSON}" | write_file "${BYRON_GENESIS_JSON}"
}

export_environment() {
export CARDANO_CONFIG
export CARDANO_DATABASE_PATH="/opt/cardano-node/data/db"
export CARDANO_NETWORK=devnet
export CARDANO_SOCKET_PATH="/opt/cardano-node/data/db/dingo.socket"
export CARDANO_TOPOLOGY="${CONFIG_PATH}/topology-dingo.json"
}

# Establish run order
main() {
config_config_json
config_topology_json
set_start_time
export_environment
/bin/dingo
exit_code=$?
if [ ${exit_code} -eq 1 ]; then
echo "exit code: 0"
exit 0
else
echo "exit code: ${exit_code}"
exit ${?}
fi
}

main
2 changes: 1 addition & 1 deletion compose/testnets/cardano_node_10.4.1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ A 5 pools testnet using cardano-node version 10.4.1 testing consistency between

## Testnet

- **Pools**: 3
- **Pools**: 5
13 changes: 13 additions & 0 deletions compose/testnets/cardano_node_10.4.1_dingo_0.12.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Description

A 5 pools testnet using cardano-node version 10.4.1 testing consistency between nodes runnning UTxO-HD with LMDB and in-memory: We run 3 nodes with in-memory DB and 2 node with LMDB and check they are still consistent. A single Dingo 0.12.0 node is added to the network as a client not producing blocks.

## Cardano-Node

- **Version**: 10.4.1
- **Branch**: -
- **Source/Compiled**: Compiled

## Testnet

- **Pools**: 5
Loading