-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from cardano-foundation/feat/is-42-setup-mithirl
feat: IS-42 setup mithril network with docker
- Loading branch information
Showing
6 changed files
with
307 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
|
||
# Mithril genesis keys | ||
GENESIS_VERIFICATION_KEY=5b33322c3235332c3138362c3230312c3137372c31312c3131372c3133352c3138372c3136372c3138312c3138382c32322c35392c3230362c3130352c3233312c3135302c3231352c33302c37382c3231322c37362c31362c3235322c3138302c37322c3133342c3133372c3234372c3136312c36385d | ||
GENESIS_SECRET_KEY=5b3131382c3138342c3232342c3137332c3136302c3234312c36312c3134342c36342c39332c3130362c3232392c38332c3133342c3138392c34302c3138392c3231302c32352c3138342c3136302c3134312c3233372c32362c3136382c35342c3233392c3230342c3133392c3131392c31332c3139395d | ||
CHAIN_OBSERVER_TYPE=pallas | ||
CARDANO_NODE_DIR=chains/cardano/devnet | ||
CARDANO_NODE_VERSION=8.9.1 | ||
MITHRIL_DATA_DIR=chains/mithrils/data | ||
|
||
cat >> docker-compose.yaml <<EOF | ||
version: "3.9" | ||
services: | ||
EOF | ||
|
||
cat >> docker-compose.yaml <<EOF | ||
mithril-aggregator: | ||
image: \${MITHRIL_AGGREGATOR_IMAGE} | ||
restart: always | ||
profiles: | ||
- mithril | ||
volumes: | ||
- ./${CARDANO_NODE_DIR}:/data:z | ||
- ./${MITHRIL_DATA_DIR}:/mithril:z | ||
networks: | ||
- mithril_network | ||
ports: | ||
- "8080:8080" | ||
environment: | ||
- RUST_BACKTRACE=1 | ||
- GOOGLE_APPLICATION_CREDENTIALS_JSON= | ||
- NETWORK=devnet | ||
- NETWORK_MAGIC=42 | ||
- PROTOCOL_PARAMETERS__K=5 | ||
- PROTOCOL_PARAMETERS__M=100 | ||
- PROTOCOL_PARAMETERS__PHI_F=0.65 | ||
- RUN_INTERVAL=6000 | ||
- URL_SNAPSHOT_MANIFEST= | ||
- SNAPSHOT_STORE_TYPE=local | ||
- SNAPSHOT_UPLOADER_TYPE=local | ||
- SNAPSHOT_COMPRESSION_ALGORITHM=zstandard | ||
- DATA_STORES_DIRECTORY=/mithril/aggregator/stores | ||
- CARDANO_NODE_SOCKET_PATH=/data/node.socket | ||
- CARDANO_NODE_VERSION=${CARDANO_NODE_VERSION} | ||
- CARDANO_CLI_PATH=/app/bin/cardano-cli | ||
- CHAIN_OBSERVER_TYPE=${CHAIN_OBSERVER_TYPE} | ||
- GENESIS_VERIFICATION_KEY=${GENESIS_VERIFICATION_KEY} | ||
- DB_DIRECTORY=/data/db | ||
- SNAPSHOT_DIRECTORY=/mithril/aggregator | ||
- SERVER_PORT=8080 | ||
- SIGNED_ENTITY_TYPES=CardanoTransactions | ||
- CURRENT_ERA_EPOCH=0 | ||
- ERA_ADAPTER_TYPE=bootstrap | ||
command: | ||
[ | ||
"-vvv", | ||
"serve" | ||
] | ||
mithril-aggregator-genesis: | ||
image: \${MITHRIL_AGGREGATOR_IMAGE} | ||
profiles: | ||
- mithril-genesis | ||
volumes: | ||
- ./${CARDANO_NODE_DIR}:/data:z | ||
- ./${MITHRIL_DATA_DIR}:/mithril:z | ||
networks: | ||
- mithril_network | ||
ports: | ||
- "8080:8080" | ||
environment: | ||
- RUST_BACKTRACE=1 | ||
- GOOGLE_APPLICATION_CREDENTIALS_JSON= | ||
- NETWORK=devnet | ||
- NETWORK_MAGIC=42 | ||
- PROTOCOL_PARAMETERS__K=5 | ||
- PROTOCOL_PARAMETERS__M=100 | ||
- PROTOCOL_PARAMETERS__PHI_F=0.65 | ||
- RUN_INTERVAL=6000 | ||
- URL_SNAPSHOT_MANIFEST= | ||
- SNAPSHOT_STORE_TYPE=local | ||
- SNAPSHOT_UPLOADER_TYPE=local | ||
- SNAPSHOT_COMPRESSION_ALGORITHM=zstandard | ||
- DATA_STORES_DIRECTORY=/mithril/aggregator/stores | ||
- CARDANO_NODE_SOCKET_PATH=/data/node.socket | ||
- CARDANO_NODE_VERSION=${CARDANO_NODE_VERSION} | ||
- CARDANO_CLI_PATH=/app/bin/cardano-cli | ||
- CHAIN_OBSERVER_TYPE=${CHAIN_OBSERVER_TYPE} | ||
- GENESIS_VERIFICATION_KEY=${GENESIS_VERIFICATION_KEY} | ||
- GENESIS_SECRET_KEY=${GENESIS_SECRET_KEY} | ||
- DB_DIRECTORY=/data/db | ||
- SNAPSHOT_DIRECTORY=/mithril/aggregator | ||
- SERVER_PORT=8080 | ||
- SIGNED_ENTITY_TYPES=CardanoTransactions | ||
- CURRENT_ERA_EPOCH=0 | ||
- ERA_ADAPTER_TYPE=bootstrap | ||
command: | ||
[ | ||
"-vvv", | ||
"genesis", | ||
"bootstrap" | ||
] | ||
EOF | ||
|
||
NUM_POOL_NODES=2 | ||
for (( i=1; i<=${NUM_POOL_NODES}; i++ )) do | ||
cat >> docker-compose.yaml <<EOF | ||
mithril-signer-${i}: | ||
image: \${MITHRIL_SIGNER_IMAGE} | ||
restart: always | ||
profiles: | ||
- mithril | ||
volumes: | ||
- ./${CARDANO_NODE_DIR}:/data:z | ||
- ./${MITHRIL_DATA_DIR}:/mithril:z | ||
networks: | ||
- mithril_network | ||
environment: | ||
- RUST_BACKTRACE=1 | ||
- AGGREGATOR_ENDPOINT=http://mithril-aggregator:8080/aggregator | ||
- NETWORK=devnet | ||
- NETWORK_MAGIC=42 | ||
- RUN_INTERVAL=2000 | ||
- DB_DIRECTORY=/data/db | ||
- DATA_STORES_DIRECTORY=/mithril/signer-${i}/stores | ||
- CARDANO_NODE_SOCKET_PATH=/data/node.socket | ||
- CARDANO_CLI_PATH=/app/bin/cardano-cli | ||
- KES_SECRET_KEY_PATH=/data/kes.skey | ||
- OPERATIONAL_CERTIFICATE_PATH=/data/opcert.cert | ||
- SIGNED_ENTITY_TYPES=CardanoTransactions | ||
command: | ||
[ | ||
"-vvv" | ||
] | ||
EOF | ||
|
||
done | ||
|
||
cat >> docker-compose.yaml <<EOF | ||
networks: | ||
mithril_network: | ||
driver: bridge | ||
cardano_network: | ||
driver: bridge | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Get the operating system | ||
UNAME=$(uname -s) OPERATING_SYSTEM= | ||
case $UNAME in | ||
Darwin ) OPERATING_SYSTEM="macos";; | ||
Linux ) OPERATING_SYSTEM="linux";; | ||
* ) echo "Error: Unsupported operating system. This script can only be run on Linux or MacOS." | ||
exit 1;; | ||
esac | ||
|
||
# Cardano node version | ||
if [ -z "${CARDANO_NODE_VERSION}" ]; then | ||
CARDANO_NODE_VERSION="8.7.3" | ||
fi | ||
if [ -z "${CARDANO_NODE_VERSION_RELEASE}" ]; then | ||
CARDANO_NODE_VERSION_RELEASE=$(echo ${CARDANO_NODE_VERSION} | cut -d'-' -f1) | ||
fi | ||
if [ -z "${CARDANO_BINARY_URL}" ]; then | ||
CARDANO_BINARY_URL="https://github.com/input-output-hk/cardano-node/releases/download/${CARDANO_NODE_VERSION}/cardano-node-${CARDANO_NODE_VERSION_RELEASE}-${OPERATING_SYSTEM}.tar.gz" | ||
fi | ||
|
||
ARTIFACTS_DIR=./chains/mithrils/data | ||
# Check if root directory already exists | ||
if ! mkdir -p "${ARTIFACTS_DIR}"; then | ||
echo "The ${ARTIFACTS_DIR} directory already exists, please move or remove it" | ||
fi | ||
|
||
# Check if docker-compose.yaml file is already existed | ||
DOCKER_FILE=./docker-compose.yaml | ||
if [ -f "${DOCKER_FILE}" ]; then | ||
rm -f ${DOCKER_FILE} | ||
fi | ||
|
||
# Check if the cardano-cli & cardano-node binaries are already downloaded | ||
CARDANO_CLI_FILE=./cardano-cli | ||
# Check if the cardano-cli file exists | ||
if [ -f "${CARDANO_CLI_FILE}" ]; then | ||
echo "The cardano-cli file does not exist. Please download it." | ||
return | ||
fi | ||
|
||
# Download cardano-cli & cardano-node if enabled (default: yes) | ||
if [[ "$SKIP_CARDANO_BIN_DOWNLOAD" != "true" ]]; then | ||
echo ">> Downloading cardano-cli & cardano-node..." | ||
curl -sL ${CARDANO_BINARY_URL} --output cardano-bin.tar.gz | ||
tar xzf cardano-bin.tar.gz ./bin/cardano-cli ./bin/cardano-node && mv ./bin/cardano-{cli,node} . && rm -rf ./bin || tar xzf cardano-bin.tar.gz ./cardano-cli ./cardano-node | ||
rm -f cardano-bin.tar.gz | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env bash | ||
echo ">> Start Mithril network" | ||
if [ -z "${MITHRIL_IMAGE_ID}" ]; then | ||
export MITHRIL_AGGREGATOR_IMAGE="mithril/mithril-aggregator" | ||
export MITHRIL_CLIENT_IMAGE="mithril/mithril-client" | ||
export MITHRIL_SIGNER_IMAGE="mithril/mithril-signer" | ||
echo ">> Build Mithril node Docker images" | ||
cd chains/mithrils/mithril | ||
if [ -z "${MITHRIL_NODE_DOCKER_BUILD_TYPE}" ]; then | ||
MITHRIL_NODE_DOCKER_BUILD_TYPE=ci | ||
fi | ||
if [ -z "${MITHRIL_NODE_DOCKER_CI_IMAGE_FROM}" ]; then | ||
MITHRIL_NODE_DOCKER_CI_IMAGE_FROM=debian:12-slim | ||
fi | ||
export DOCKER_IMAGE_FROM=$MITHRIL_NODE_DOCKER_CI_IMAGE_FROM | ||
if [ "${MITHRIL_NODE_DOCKER_BUILD_TYPE}" = "ci" ]; then | ||
DOCKER_BUILD_CMD="make docker-build-ci" | ||
else | ||
DOCKER_BUILD_CMD="make docker-build" | ||
fi | ||
export CARDANO_NODE_VERSION=8.7.3 | ||
echo ">>>> Docker builder will use Cardano node version: '$CARDANO_NODE_VERSION'" | ||
echo ">>>> Docker builder will build images with command: '$DOCKER_BUILD_CMD'" | ||
echo ">>>> Building Mithril Aggregator node Docker image" | ||
cd mithril-aggregator && $DOCKER_BUILD_CMD && cd .. | ||
echo ">>>> Building Mithril Signer node Docker image" | ||
cd mithril-signer && $DOCKER_BUILD_CMD && cd .. | ||
cd ../../.. | ||
else | ||
export MITHRIL_AGGREGATOR_IMAGE="ghcr.io/input-output-hk/mithril-aggregator:${MITHRIL_IMAGE_ID}" | ||
export MITHRIL_CLIENT_IMAGE="ghcr.io/input-output-hk/mithril-client:${MITHRIL_IMAGE_ID}" | ||
export MITHRIL_SIGNER_IMAGE="ghcr.io/input-output-hk/mithril-signer:${MITHRIL_IMAGE_ID}" | ||
fi | ||
|
||
docker compose rm -f | ||
docker compose -f docker-compose.yaml --profile mithril up --remove-orphans --force-recreate -d --no-build | ||
|
||
# echo ">> List of Mithril signers" | ||
# echo --------,--------------------------------------------------------,----------------------------------- | column -t -s, | ||
# cat node-pool1/info.json | jq -r '"\(.name),\(.pool_id),\(.description)"' | column -t -s, | ||
# cat node-pool2/info.json | jq -r '"\(.name),\(.pool_id),\(.description)"' | column -t -s, | ||
|
||
echo ">> Wait for Mithril signers to be registered" | ||
EPOCH_NOW=$(CARDANO_NODE_SOCKET_PATH=chains/cardano/devnet/node.socket ./cardano-cli query tip --cardano-mode --testnet-magic 42 2> /dev/null | jq -r .epoch) | ||
while true | ||
do | ||
EPOCH=$(CARDANO_NODE_SOCKET_PATH=chains/cardano/devnet/node.socket ./cardano-cli query tip --cardano-mode --testnet-magic 42 2> /dev/null | jq -r .epoch) | ||
EPOCH_DELTA=$(( $EPOCH - $EPOCH_NOW )) | ||
if [ $EPOCH_DELTA -ge 2 ] ; then | ||
echo ">>>> Ready!" | ||
break | ||
else | ||
echo ">>>> Not ready yet" | ||
sleep 2 | ||
fi | ||
done | ||
|
||
echo ">> Bootstrap the Genesis certificate" | ||
docker compose -f docker-compose.yaml --profile mithril-genesis run mithril-aggregator-genesis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo ">> Stop Cardano network" | ||
killall cardano-node | ||
|
||
echo ">> Stop Mithril network" | ||
if [ -z "${MITHRIL_IMAGE_ID}" ]; then | ||
export MITHRIL_AGGREGATOR_IMAGE="mithril/mithril-aggregator" | ||
export MITHRIL_CLIENT_IMAGE="mithril/mithril-client" | ||
export MITHRIL_SIGNER_IMAGE="mithril/mithril-signer" | ||
else | ||
export MITHRIL_AGGREGATOR_IMAGE="ghcr.io/input-output-hk/mithril-aggregator:${MITHRIL_IMAGE_ID}" | ||
export MITHRIL_CLIENT_IMAGE="ghcr.io/input-output-hk/mithril-client:${MITHRIL_IMAGE_ID}" | ||
export MITHRIL_SIGNER_IMAGE="ghcr.io/input-output-hk/mithril-signer:${MITHRIL_IMAGE_ID}" | ||
fi | ||
docker compose -f docker-compose.yaml --profile mithril down |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
# Debug mode | ||
if [[ -n $DEBUG ]]; then | ||
set -x | ||
fi | ||
|
||
# Script directory variable | ||
ROOT_DIR=$(dirname $(realpath $0)) | ||
|
||
SCRIPT_DIRECTORY=${ROOT_DIR}/chains/mithrils/scripts | ||
|
||
# Change directory | ||
pushd ${ROOT_DIR} > /dev/null | ||
|
||
# Init script | ||
. $SCRIPT_DIRECTORY/mkfiles-init.sh | ||
|
||
# Generate the docker files | ||
. $SCRIPT_DIRECTORY/mkfiles-docker.sh | ||
|
||
# Start devnet Mithril nodes | ||
echo ">> Info: Mithril Aggregator will be attached to the first Cardano BFT node" | ||
echo ">> Info: Mithril Signers will be attached to each Cardano SPO node" | ||
echo "=====================================================================" | ||
echo " Start Mithril nodes" | ||
echo "=====================================================================" | ||
echo | ||
. $SCRIPT_DIRECTORY/start-mithril.sh | ||
echo |