Skip to content

Commit

Permalink
Add relay/block producer Cardano nodes
Browse files Browse the repository at this point in the history
For verified signers.
  • Loading branch information
jpraynaud committed Nov 29, 2022
1 parent 6ec79b5 commit f839c09
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 22 deletions.
Expand Up @@ -20,7 +20,7 @@ services:
max-file: "5"
volumes:
- ./cardano-configurations/network/${NETWORK}:/config
- ../data/${NETWORK}/mithril-signer-${SIGNER_ID}/cardano/db:/db
- ../data/${NETWORK}/mithril-signer-${SIGNER_ID}/cardano/db/passive:/db
- ../data/${NETWORK}/mithril-signer-${SIGNER_ID}/cardano/ipc:/ipc
environment:
- CARDANO_SOCKET_PATH=/ipc/node.socket
Expand Down Expand Up @@ -57,7 +57,7 @@ services:
- CARDANO_CLI_PATH=/app/bin/cardano-cli
volumes:
- ../data/${NETWORK}/mithril-signer-${SIGNER_ID}/mithril:/mithril-signer-${SIGNER_ID}/mithril
- ../data/${NETWORK}/mithril-signer-${SIGNER_ID}/cardano/db:/mithril-signer-${SIGNER_ID}/cardano/db
- ../data/${NETWORK}/mithril-signer-${SIGNER_ID}/cardano/db/passive:/mithril-signer-${SIGNER_ID}/cardano/db
- ../data/${NETWORK}/mithril-signer-${SIGNER_ID}/cardano/ipc:/ipc
depends_on:
cardano-node-signer:
Expand Down
62 changes: 49 additions & 13 deletions mithril-infra/assets/docker/docker-compose-signer-verified.yaml
Expand Up @@ -3,9 +3,9 @@
version: "3.9"

services:
cardano-node-signer:
cardano-node-signer-relay:
image: cardano-node/1.35.4-modified
container_name: cardano-node-signer-${SIGNER_ID}
container_name: cardano-node-relay-signer-${SIGNER_ID}
build:
context: .
dockerfile: Dockerfile.cardano
Expand All @@ -20,12 +20,12 @@ services:
max-file: "5"
volumes:
- ./cardano-configurations/network/${NETWORK}:/config
- ../data/${NETWORK}/mithril-signer-${SIGNER_ID}/cardano/db:/db
- ../data/${NETWORK}/mithril-signer-${SIGNER_ID}/cardano/db/relay:/db
- ../data/${NETWORK}/mithril-signer-${SIGNER_ID}/cardano/ipc:/ipc
- ../data/${NETWORK}/mithril-signer-${SIGNER_ID}/cardano/pool:/pool
- ../data/${NETWORK}/mithril-signer-${SIGNER_ID}/cardano/www:/www
ports:
- "${SIGNER_CARDANO_PORT}:${SIGNER_CARDANO_PORT}"
- "${SIGNER_CARDANO_RELAY_PORT}:${SIGNER_CARDANO_RELAY_PORT}"
environment:
- CARDANO_SOCKET_PATH=/ipc/node.socket
- CARDANO_NODE_SOCKET_PATH=/ipc/node.socket
Expand All @@ -35,13 +35,50 @@ services:
"--config",
"/config/cardano-node/config.json",
"--topology",
"/config/cardano-node/topology.json",
"/pool/topology-relay.json",
"--database-path",
"/db",
"--host-addr",
"${SIGNER_CARDANO_ADDR}",
"--port",
"${SIGNER_CARDANO_PORT}",
"${SIGNER_CARDANO_RELAY_PORT}"
]

cardano-node-signer-block-producer:
image: cardano-node/1.35.4-modified
container_name: cardano-node-block-producer-signer-${SIGNER_ID}
build:
context: .
dockerfile: Dockerfile.cardano
user: ${CURRENT_UID}
profiles:
- cardano
- all
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "5"
volumes:
- ./cardano-configurations/network/${NETWORK}:/config
- ../data/${NETWORK}/mithril-signer-${SIGNER_ID}/cardano/db/block-producer:/db
- ../data/${NETWORK}/mithril-signer-${SIGNER_ID}/cardano/ipc:/ipc
- ../data/${NETWORK}/mithril-signer-${SIGNER_ID}/cardano/pool:/pool
- ../data/${NETWORK}/mithril-signer-${SIGNER_ID}/cardano/www:/www
ports:
- "${SIGNER_CARDANO_BLOCK_PRODUCER_PORT}:${SIGNER_CARDANO_BLOCK_PRODUCER_PORT}"
environment:
- CARDANO_SOCKET_PATH=/ipc/node.socket
- CARDANO_NODE_SOCKET_PATH=/ipc/node.socket
command:
[
"run",
"--config",
"/config/cardano-node/config.json",
"--topology",
"/pool/topology-block-producer.json",
"--database-path",
"/db",
"--port",
"${SIGNER_CARDANO_BLOCK_PRODUCER_PORT}",
"--shelley-kes-key",
"/pool/kes.skey",
"--shelley-vrf-key",
Expand Down Expand Up @@ -72,12 +109,14 @@ services:
- CARDANO_CLI_PATH=/app/bin/cardano-cli
volumes:
- ../data/${NETWORK}/mithril-signer-${SIGNER_ID}/mithril:/mithril-signer-${SIGNER_ID}/mithril
- ../data/${NETWORK}/mithril-signer-${SIGNER_ID}/cardano/db:/mithril-signer-${SIGNER_ID}/cardano/db
- ../data/${NETWORK}/mithril-signer-${SIGNER_ID}/cardano/db/block-producer:/mithril-signer-${SIGNER_ID}/cardano/db
- ../data/${NETWORK}/mithril-signer-${SIGNER_ID}/cardano/pool:/mithril-signer-${SIGNER_ID}/cardano/pool
- ../data/${NETWORK}/mithril-signer-${SIGNER_ID}/cardano/ipc:/ipc
- ./cardano-configurations/network/${NETWORK}:/config
depends_on:
cardano-node-signer:
cardano-node-signer-block-producer:
condition: service_started
cardano-node-signer-relay:
condition: service_started
logging:
driver: "json-file"
Expand All @@ -96,9 +135,6 @@ services:
- ../data/${NETWORK}/mithril-signer-${SIGNER_ID}/cardano/www:/usr/share/nginx/html
ports:
- "${SIGNER_WWW_PORT}:8080"
depends_on:
cardano-node-signer:
condition: service_started
logging:
driver: "json-file"
options:
Expand Down
2 changes: 1 addition & 1 deletion mithril-infra/main.firewall.tf
Expand Up @@ -4,7 +4,7 @@ resource "google_compute_firewall" "mithril-vm-firewall" {

allow {
protocol = "tcp"
ports = concat(["22", "80", "443"], values(local.mithril_signers_cardano_port))
ports = concat(["22", "80", "443"], values(local.mithril_signers_relay_cardano_port))
}

source_ranges = ["0.0.0.0/0"]
Expand Down
32 changes: 26 additions & 6 deletions mithril-infra/mithril.signer.tf
@@ -1,7 +1,8 @@
locals {
mithril_signers_index = [for key, signer in var.mithril_signers : key]
mithril_signers_www_port = { for key, signer in var.mithril_signers : key => index(local.mithril_signers_index, key) + 1 + 8080 }
mithril_signers_cardano_port = { for key, signer in var.mithril_signers : key => index(local.mithril_signers_index, key) + 1 + 9090 }
mithril_signers_index = [for key, signer in var.mithril_signers : key]
mithril_signers_www_port = { for key, signer in var.mithril_signers : key => index(local.mithril_signers_index, key) + 1 + 8080 }
mithril_signers_relay_cardano_port = { for key, signer in var.mithril_signers : key => index(local.mithril_signers_index, key) + 1 + 9090 }
mithril_signers_block_producer_cardano_port = { for key, signer in var.mithril_signers : key => index(local.mithril_signers_index, key) + 1 + 10000 }
}
resource "null_resource" "mithril_signer" {
for_each = var.mithril_signers
Expand All @@ -25,12 +26,29 @@ resource "null_resource" "mithril_signer" {
inline = [
"mkdir -p /home/curry/data/${var.cardano_network}",
"mkdir -p /home/curry/data/${var.cardano_network}/mithril-signer-${each.key}/cardano/db",
"mkdir -p /home/curry/data/${var.cardano_network}/mithril-signer-${each.key}/cardano/db/passive",
"mkdir -p /home/curry/data/${var.cardano_network}/mithril-signer-${each.key}/cardano/db/block-producer",
"mkdir -p /home/curry/data/${var.cardano_network}/mithril-signer-${each.key}/cardano/db/relay",
"mkdir -p /home/curry/data/${var.cardano_network}/mithril-signer-${each.key}/cardano/ipc",
"mkdir -p /home/curry/data/${var.cardano_network}/mithril-signer-${each.key}/cardano/pool",
"mkdir -p /home/curry/data/${var.cardano_network}/mithril-signer-${each.key}/cardano/www",
"mkdir -p /home/curry/data/${var.cardano_network}/mithril-signer-${each.key}/mithril/stores",
"mkdir -p /home/curry/data/${var.cardano_network}/mithril-signer-${each.key}/mithril/snapshots",
"echo -n ${local.mithril_signers_cardano_port[each.key]} > /home/curry/data/${var.cardano_network}/mithril-signer-${each.key}/cardano/pool/port"
"echo -n ${local.mithril_signers_relay_cardano_port[each.key]} > /home/curry/data/${var.cardano_network}/mithril-signer-${each.key}/cardano/pool/port",
<<-EOT
cat > /home/curry/data/${var.cardano_network}/mithril-signer-${each.key}/cardano/pool/topology-block-producer.json << EOF
{
"Producers": [
{
"addr": "${google_compute_address.mithril-external-address.address}",
"port": ${local.mithril_signers_relay_cardano_port[each.key]},
"valency": 1
}
]
}
EOF
cat /home/curry/docker/cardano-configurations/network/preview/cardano-node/topology.json | jq '.Producers[1] |= . + { "addr": "${google_compute_address.mithril-external-address.address}", "port": ${local.mithril_signers_block_producer_cardano_port[each.key]}, "valency": 1}' > /home/curry/data/${var.cardano_network}/mithril-signer-${each.key}/cardano/pool/topology-relay.json
EOT
]
}

Expand All @@ -42,8 +60,10 @@ resource "null_resource" "mithril_signer" {
"export IMAGE_ID=${var.mithril_image_id}",
"export SIGNER_HOST=${local.mithril_signers_host[each.key]}",
"export SIGNER_WWW_PORT=${local.mithril_signers_www_port[each.key]}",
"export SIGNER_CARDANO_ADDR=0.0.0.0",
"export SIGNER_CARDANO_PORT=${local.mithril_signers_cardano_port[each.key]}",
"export SIGNER_CARDANO_RELAY_ADDR=0.0.0.0",
"export SIGNER_CARDANO_RELAY_PORT=${local.mithril_signers_relay_cardano_port[each.key]}",
"export SIGNER_CARDANO_BLOCK_PRODUCER_ADDR=0.0.0.0",
"export SIGNER_CARDANO_BLOCK_PRODUCER_PORT=${local.mithril_signers_block_producer_cardano_port[each.key]}",
"export CURRENT_UID=$(id -u)",
"export DOCKER_GID=$(getent group docker | cut -d: -f3)",
"docker-compose -p $SIGNER_ID -f /home/curry/docker/docker-compose-signer-${each.value.type}.yaml --profile all up -d",
Expand Down

0 comments on commit f839c09

Please sign in to comment.