Skip to content

Commit 6598030

Browse files
committed
feat: use local copy Cardano configurations in infra
Retrieved from https://book.play.dev.cardano.org/
1 parent 037c0c5 commit 6598030

File tree

4 files changed

+61
-42
lines changed

4 files changed

+61
-42
lines changed

mithril-infra/mithril.aggregator.tf

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ resource "null_resource" "mithril_aggregator" {
1212
vm_instance = google_compute_instance.vm_instance.id,
1313
cardano_image_id = var.cardano_image_id,
1414
cardano_image_registry = var.cardano_image_registry,
15-
cardano_configurations_repository_commit = var.cardano_configurations_repository_commit,
1615
image_id = var.mithril_image_id,
1716
mithril_aggregator_auth_username = var.mithril_aggregator_auth_username,
1817
mithril_aggregator_auth_password = var.mithril_aggregator_auth_password
@@ -43,11 +42,30 @@ resource "null_resource" "mithril_aggregator" {
4342
<<-EOT
4443
set -e
4544
# Setup cardano node configuration
46-
AGGREGATOR_CONFIG_DIRECTORY=/home/curry/data/${var.cardano_network}/mithril-aggregator/cardano/config
47-
cp -R /home/curry/docker/cardano-configurations/network/${var.cardano_network} $AGGREGATOR_CONFIG_DIRECTORY
48-
cat $AGGREGATOR_CONFIG_DIRECTORY/${var.cardano_network}/cardano-node/config.json | jq ".hasPrometheus[0] |= \"cardano-node-aggregator\"" > $AGGREGATOR_CONFIG_DIRECTORY/${var.cardano_network}/cardano-node/config.json.new
49-
rm -f $AGGREGATOR_CONFIG_DIRECTORY/${var.cardano_network}/cardano-node/config.json
50-
mv $AGGREGATOR_CONFIG_DIRECTORY/${var.cardano_network}/cardano-node/config.json.new $AGGREGATOR_CONFIG_DIRECTORY/${var.cardano_network}/cardano-node/config.json
45+
# Copy the cardano node configuration files to the aggregator (exact version, and fallback to minor version)
46+
CARDANO_NODE_EXACT_VERSION="${var.cardano_image_id}"
47+
CARDANO_NODE_MINOR_VERSION=$(echo $CARDANO_NODE_EXACT_VERSION | cut -d. -f1,2)
48+
CARDANO_NODE_VERSIONS="$CARDANO_NODE_EXACT_VERSION $CARDANO_NODE_MINOR_VERSION"
49+
FOUND_CONFIGURATION=false
50+
for CARDANO_NODE_VERSION in $CARDANO_NODE_VERSIONS; do
51+
if [ -d "/home/curry/docker/cardano/config/$CARDANO_NODE_VERSION/${var.cardano_network}" ]; then
52+
AGGREGATOR_CONFIG_DIRECTORY=/home/curry/data/${var.cardano_network}/mithril-aggregator/cardano/config
53+
rm -rf $AGGREGATOR_CONFIG_DIRECTORY
54+
mkdir -p $AGGREGATOR_CONFIG_DIRECTORY
55+
cp -R /home/curry/docker/cardano/config/$CARDANO_NODE_VERSION/${var.cardano_network} $AGGREGATOR_CONFIG_DIRECTORY
56+
echo $CARDANO_NODE_VERSION > $AGGREGATOR_CONFIG_DIRECTORY/config.version
57+
cat $AGGREGATOR_CONFIG_DIRECTORY/${var.cardano_network}/cardano-node/config.json | jq ".hasPrometheus[0] |= \"cardano-node-aggregator\"" > $AGGREGATOR_CONFIG_DIRECTORY/${var.cardano_network}/cardano-node/config.json.new
58+
rm -f $AGGREGATOR_CONFIG_DIRECTORY/${var.cardano_network}/cardano-node/config.json
59+
mv $AGGREGATOR_CONFIG_DIRECTORY/${var.cardano_network}/cardano-node/config.json.new $AGGREGATOR_CONFIG_DIRECTORY/${var.cardano_network}/cardano-node/config.json
60+
FOUND_CONFIGURATION=true
61+
break
62+
fi
63+
done
64+
# Check if a configuration was found
65+
if [ "$FOUND_CONFIGURATION" = "false" ]; then
66+
echo "No cardano node configuration found for version $CARDANO_NODE_EXACT_VERSION"
67+
exit 1
68+
fi
5169
EOT
5270
]
5371
}

mithril-infra/mithril.bootstrap.tf

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ resource "null_resource" "mithril_bootstrap" {
88
}
99

1010
triggers = {
11-
image_id = var.mithril_image_id,
12-
vm_instance = google_compute_instance.vm_instance.id,
13-
mithril_aggregator_auth_username = var.mithril_aggregator_auth_username,
14-
mithril_aggregator_auth_password = var.mithril_aggregator_auth_password,
15-
cardano_configurations_repository_commit = var.cardano_configurations_repository_commit
11+
vm_instance = google_compute_instance.vm_instance.id,
12+
image_id = var.mithril_image_id,
13+
cardano_image_id = var.cardano_image_id,
14+
cardano_image_registry = var.cardano_image_registry,
15+
mithril_aggregator_auth_username = var.mithril_aggregator_auth_username,
16+
mithril_aggregator_auth_password = var.mithril_aggregator_auth_password,
1617
}
1718

1819
provisioner "file" {
@@ -41,20 +42,7 @@ done
4142
echo "Startup script complete!"
4243
EOT
4344
,
44-
"find /home/curry/tools -name '*.sh' -type f | xargs chmod u+x",
45-
<<-EOT
46-
# Clone Cardano configurations repository if not exists
47-
if [ ! -d "/home/curry/docker/cardano-configurations" ] ; then
48-
git clone https://github.com/input-output-hk/cardano-configurations.git /home/curry/docker/cardano-configurations
49-
fi
50-
51-
# Checkout specific commit
52-
cd /home/curry/docker/cardano-configurations
53-
git checkout .
54-
git checkout master
55-
git pull
56-
git checkout ${var.cardano_configurations_repository_commit}
57-
EOT
45+
"find /home/curry/tools -name '*.sh' -type f | xargs chmod u+x"
5846
]
5947
}
6048
}

mithril-infra/mithril.signer.tf

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ resource "null_resource" "mithril_signer" {
1515
]
1616

1717
triggers = {
18-
vm_instance = google_compute_instance.vm_instance.id,
19-
cardano_image_id = var.cardano_image_id,
20-
cardano_image_registry = var.cardano_image_registry,
21-
cardano_configurations_repository_commit = var.cardano_configurations_repository_commit,
22-
image_id = var.mithril_image_id,
18+
vm_instance = google_compute_instance.vm_instance.id,
19+
cardano_image_id = var.cardano_image_id,
20+
cardano_image_registry = var.cardano_image_registry,
21+
image_id = var.mithril_image_id,
2322
}
2423

2524
connection {
@@ -52,16 +51,36 @@ cat /home/curry/docker/cardano-configurations/network/${var.cardano_network}/car
5251
EOT
5352
,
5453
<<-EOT
54+
set -e
5555
# Setup cardano node configuration
56+
CARDANO_NODE_EXACT_VERSION="${var.cardano_image_id}"
57+
CARDANO_NODE_MINOR_VERSION=$(echo $CARDANO_NODE_EXACT_VERSION | cut -d. -f1,2)
58+
CARDANO_NODE_VERSIONS="$CARDANO_NODE_EXACT_VERSION $CARDANO_NODE_MINOR_VERSION"
5659
SIGNER_TYPES="full relay block-producer"
5760
for SIGNER_TYPE in $SIGNER_TYPES; do
58-
SIGNER_TYPE_CONFIG_DIRECTORY=/home/curry/data/${var.cardano_network}/mithril-signer-${each.key}/cardano/config/$SIGNER_TYPE
59-
mkdir -p $SIGNER_TYPE_CONFIG_DIRECTORY
60-
cp -R /home/curry/docker/cardano-configurations/network/${var.cardano_network} $SIGNER_TYPE_CONFIG_DIRECTORY
61-
cat $SIGNER_TYPE_CONFIG_DIRECTORY/${var.cardano_network}/cardano-node/config.json | jq ".hasPrometheus[0] |= \"cardano-node-$SIGNER_TYPE-signer-${each.key}\"" > $SIGNER_TYPE_CONFIG_DIRECTORY/${var.cardano_network}/cardano-node/config.json.new
62-
rm -f $SIGNER_TYPE_CONFIG_DIRECTORY/${var.cardano_network}/cardano-node/config.json
63-
mv $SIGNER_TYPE_CONFIG_DIRECTORY/${var.cardano_network}/cardano-node/config.json.new $SIGNER_TYPE_CONFIG_DIRECTORY/${var.cardano_network}/cardano-node/config.json
61+
# Copy the cardano node configuration files to the signer (exact version, and fallback to minor version)
62+
FOUND_CONFIGURATION=false
63+
for CARDANO_NODE_VERSION in $CARDANO_NODE_VERSIONS; do
64+
if [ -d "/home/curry/docker/cardano/config/$CARDANO_NODE_VERSION/${var.cardano_network}" ]; then
65+
SIGNER_TYPE_CONFIG_DIRECTORY=/home/curry/data/${var.cardano_network}/mithril-signer-${each.key}/cardano/config/$SIGNER_TYPE
66+
rm -rf $SIGNER_TYPE_CONFIG_DIRECTORY
67+
mkdir -p $SIGNER_TYPE_CONFIG_DIRECTORY
68+
cp -R /home/curry/docker/cardano/config/$CARDANO_NODE_VERSION/${var.cardano_network} $SIGNER_TYPE_CONFIG_DIRECTORY
69+
echo $CARDANO_NODE_VERSION > $SIGNER_TYPE_CONFIG_DIRECTORY/config.version
70+
cat $SIGNER_TYPE_CONFIG_DIRECTORY/${var.cardano_network}/cardano-node/config.json | jq ".hasPrometheus[0] |= \"cardano-node-$SIGNER_TYPE-signer-${each.key}\"" > $SIGNER_TYPE_CONFIG_DIRECTORY/${var.cardano_network}/cardano-node/config.json.new
71+
rm -f $SIGNER_TYPE_CONFIG_DIRECTORY/${var.cardano_network}/cardano-node/config.json
72+
mv $SIGNER_TYPE_CONFIG_DIRECTORY/${var.cardano_network}/cardano-node/config.json.new $SIGNER_TYPE_CONFIG_DIRECTORY/${var.cardano_network}/cardano-node/config.json
73+
FOUND_CONFIGURATION=true
74+
break
75+
fi
76+
done
77+
# Check if a configuration was found
78+
if [ "$FOUND_CONFIGURATION" = "false" ]; then
79+
echo "No cardano node configuration found for version $CARDANO_NODE_EXACT_VERSION of type $SIGNER_TYPE"
80+
exit 1
81+
fi
6482
done
83+
6584
EOT
6685
]
6786
}

mithril-infra/variables.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,6 @@ variable "cardano_image_registry" {
150150
default = "ghcr.io/intersectmbo/cardano-node"
151151
}
152152

153-
variable "cardano_configurations_repository_commit" {
154-
type = string
155-
description = "The Cardano configurations commit to use"
156-
default = "32581b26b6d3534582cd7fb2af133e655a925349"
157-
}
158-
159153
variable "mithril_api_domain" {
160154
type = string
161155
description = "The Mithril api (sub)domain name of service to deploy"

0 commit comments

Comments
 (0)