Skip to content

Commit

Permalink
add auto domain to infra
Browse files Browse the repository at this point in the history
  • Loading branch information
DaMandal0rian committed May 7, 2024
1 parent 9d5caae commit 3d73464
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 23 deletions.
4 changes: 2 additions & 2 deletions resources/devnet/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ variable "farmer_reward_address" {
variable "domain_id" {
description = "Domain ID"
type = list(number)
default = [0]
default = [0, 1]
}

variable "domain_labels" {
description = "Tag of the domain to run"
type = list(string)
default = ["evm"]
default = ["evm", "auto"]
}

variable "instance_type" {
Expand Down
16 changes: 14 additions & 2 deletions templates/scripts/create_bootstrap_node_evm_compose_file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ if [ "${enable_domains}" == "true" ]; then
{
# core domain
echo ' "--",'
echo ' "--domain-id", "${DOMAIN_ID}",'
echo ' "--domain-id", "${DOMAIN_ID_EVM}",'
echo ' "--state-pruning", "archive",'
echo ' "--blocks-pruning", "archive",'
echo ' "--listen-on", "/ip4/0.0.0.0/tcp/${OPERATOR_PORT}",'
Expand All @@ -192,7 +192,19 @@ if [ "${enable_domains}" == "true" ]; then
echo " \"--reserved-nodes\", \"${addr}\"," >> ~/subspace/docker-compose.yml
echo " \"--bootstrap-nodes\", \"${addr}\"," >> ~/subspace/docker-compose.yml
done

# auto domain
echo ' "--",'
echo ' "--domain-id", "${DOMAIN_ID_AUTO}",'
echo ' "--state-pruning", "archive",'
echo ' "--blocks-pruning", "archive",'
echo ' "--listen-on", "/ip4/0.0.0.0/tcp/${OPERATOR_PORT}",'
echo ' "--rpc-cors", "all",'
echo ' "--rpc-listen-on", "0.0.0.0:7944",'
for (( i = 0; i < node_count; i++ )); do
addr=$(sed -nr "s/NODE_${i}_OPERATOR_MULTI_ADDR_TCP=//p" ~/subspace/node_keys.txt)
echo " \"--reserved-nodes\", \"${addr}\"," >> ~/subspace/docker-compose.yml
echo " \"--bootstrap-nodes\", \"${addr}\"," >> ~/subspace/docker-compose.yml
done
} >> ~/subspace/docker-compose.yml
fi
echo ' ]' >> ~/subspace/docker-compose.yml
22 changes: 20 additions & 2 deletions templates/scripts/create_domain_node_compose_file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,17 @@ services:
labels:
- "traefik.enable=true"
- "traefik.http.services.archival-node.loadbalancer.server.port=8944"
- "traefik.http.routers.archival-node.rule=Host(\`\${DOMAIN_PREFIX}-\${DOMAIN_ID}.\${DOMAIN_LABEL}.\${NETWORK_NAME}.subspace.network\`) && Path(\`/ws\`)"
- "traefik.http.routers.archival-node.rule=Host(\`\${DOMAIN_PREFIX}-\${DOMAIN_ID_EVM}.\${DOMAIN_LABEL_EVM}.\${NETWORK_NAME}.subspace.network\`) && Path(\`/ws\`)"
- "traefik.http.routers.archival-node.tls=true"
- "traefik.http.routers.archival-node.tls.certresolver=le"
- "traefik.http.routers.archival-node.entrypoints=websecure"
- "traefik.http.routers.archival-node.middlewares=redirect-https"
- "traefik.http.routers.archival-node-auto.rule=Host(\`\${DOMAIN_PREFIX}-\${DOMAIN_ID_AUTO}.\${DOMAIN_LABEL_AUTO}.\${NETWORK_NAME}.subspace.network\`) && Path(\`/ws\`)"
- "traefik.http.routers.archival-node-auto.tls=true"
- "traefik.http.routers.archival-node-auto.tls.certresolver=le"
- "traefik.http.routers.archival-node-auto.entrypoints=websecure"
- "traefik.http.routers.archival-node-auto.middlewares=redirect-https"
- "traefik.http.services.archival-node-auto.loadbalancer.server.port=7944"
- "traefik.http.middlewares.redirect-https.redirectscheme.scheme=https"
- "traefik.http.middlewares.redirect-https.redirectscheme.permanent=true"
- "traefik.docker.network=traefik-proxy"
Expand Down Expand Up @@ -173,7 +179,19 @@ if [ "${enable_domains}" == "true" ]; then
echo " \"--reserved-nodes\", \"${addr}\"," >> ~/subspace/docker-compose.yml
echo " \"--bootstrap-nodes\", \"${addr}\"," >> ~/subspace/docker-compose.yml
done

# auto domain
echo ' "--",'
echo ' "--domain-id", "${DOMAIN_ID_AUTO}",'
echo ' "--state-pruning", "archive",'
echo ' "--blocks-pruning", "archive",'
echo ' "--listen-on", "/ip4/0.0.0.0/tcp/${OPERATOR_PORT}",'
echo ' "--rpc-cors", "all",'
echo ' "--rpc-listen-on", "0.0.0.0:7944",'
for (( i = 0; i < node_count; i++ )); do
addr=$(sed -nr "s/NODE_${i}_OPERATOR_MULTI_ADDR_TCP=//p" ~/subspace/node_keys.txt)
echo " \"--reserved-nodes\", \"${addr}\"," >> ~/subspace/docker-compose.yml
echo " \"--bootstrap-nodes\", \"${addr}\"," >> ~/subspace/docker-compose.yml
done
} >> ~/subspace/docker-compose.yml
fi

Expand Down
8 changes: 4 additions & 4 deletions templates/terraform/hetzner/bootstrap_node_evm_provisioner.tf
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ resource "null_resource" "start-bootstrap-nodes-evm" {
"echo NETWORK_NAME=${var.network_name} >> /root/subspace/.env",
"echo NODE_ID=${count.index} >> /root/subspace/.env",
"echo NODE_KEY=$(sed -nr 's/NODE_${count.index}_KEY=//p' /root/subspace/node_keys.txt) >> /root/subspace/.env",
"echo DOMAIN_LABEL=${var.domain-node-config.domain-labels[0]} >> /root/subspace/.env",
"echo DOMAIN_ID=${var.domain-node-config.domain-id[0]} >> /root/subspace/.env",
"echo RELAYER_SYSTEM_ID=$(sed -nr 's/NODE_${count.index}_RELAYER_SYSTEM_ID=//p' /root/subspace/relayer_ids.txt) >> /root/subspace/.env",
"echo RELAYER_DOMAIN_ID=$(sed -nr 's/NODE_${count.index}_RELAYER_DOMAIN_ID=//p' /root/subspace/relayer_ids.txt) >> /root/subspace/.env",
"echo DOMAIN_LABEL_EVM=${var.domain-node-config.domain-labels[0]} >> /home/${var.ssh_user}/subspace/.env",
"echo DOMAIN_ID_EVM=${var.domain-node-config.domain-id[0]} >> /home/${var.ssh_user}/subspace/.env",
"echo DOMAIN_LABEL_AUTO=${var.domain-node-config.domain-labels[1]} >> /home/${var.ssh_user}/subspace/.env",
"echo DOMAIN_ID_AUTO=${var.domain-node-config.domain-id[1]} >> /home/${var.ssh_user}/subspace/.env",
"echo PIECE_CACHE_SIZE=${var.piece_cache_size} >> /root/subspace/.env",
"echo DSN_NODE_ID=${count.index} >> /root/subspace/.env",
"echo DSN_NODE_KEY=$(sed -nr 's/NODE_${count.index}_DSN_KEY=//p' /root/subspace/node_keys.txt) >> /root/subspace/.env",
Expand Down
9 changes: 4 additions & 5 deletions templates/terraform/hetzner/domain_node_provisioner.tf
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,12 @@ resource "null_resource" "start-domain-nodes" {
"echo NODE_TAG=${var.domain-node-config.node-tag} >> /root/subspace/.env",
"echo NETWORK_NAME=${var.network_name} >> /root/subspace/.env",
"echo DOMAIN_PREFIX=${var.domain-node-config.domain-prefix} >> /root/subspace/.env",
# //todo use a map for domain id and labels
"echo DOMAIN_LABEL=${var.domain-node-config.domain-labels[0]} >> /root/subspace/.env",
"echo DOMAIN_ID=${var.domain-node-config.domain-id[0]} >> /root/subspace/.env",
"echo DOMAIN_LABEL_EVM=${var.domain-node-config.domain-labels[0]} >> /home/${var.ssh_user}/subspace/.env",
"echo DOMAIN_ID_EVM=${var.domain-node-config.domain-id[0]} >> /home/${var.ssh_user}/subspace/.env",
"echo DOMAIN_LABEL_AUTO=${var.domain-node-config.domain-labels[1]} >> /home/${var.ssh_user}/subspace/.env",
"echo DOMAIN_ID_AUTO=${var.domain-node-config.domain-id[1]} >> /home/${var.ssh_user}/subspace/.env",
"echo NODE_ID=${count.index} >> /root/subspace/.env",
"echo NODE_KEY=$(sed -nr 's/NODE_${count.index}_KEY=//p' /root/subspace/node_keys.txt) >> /root/subspace/.env",
"echo RELAYER_SYSTEM_ID=$(sed -nr 's/NODE_${count.index}_RELAYER_SYSTEM_ID=//p' /root/subspace/relayer_ids.txt) >> /root/subspace/.env",
"echo RELAYER_DOMAIN_ID=$(sed -nr 's/NODE_${count.index}_RELAYER_DOMAIN_ID=//p' /root/subspace/relayer_ids.txt) >> /root/subspace/.env",
"echo PIECE_CACHE_SIZE=${var.piece_cache_size} >> /root/subspace/.env",
"echo NODE_DSN_PORT=${var.domain-node-config.node-dsn-port} >> /root/subspace/.env",

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ resource "null_resource" "start-bootstrap-nodes-evm" {
"echo NETWORK_NAME=${var.network_name} >> /home/${var.ssh_user}/subspace/.env",
"echo NODE_ID=${count.index} >> /home/${var.ssh_user}/subspace/.env",
"echo NODE_KEY=$(sed -nr 's/NODE_${count.index}_KEY=//p' /home/${var.ssh_user}/subspace/node_keys.txt) >> /home/${var.ssh_user}/subspace/.env",
"echo DOMAIN_LABEL=${var.domain-node-config.domain-labels[0]} >> /home/${var.ssh_user}/subspace/.env",
"echo DOMAIN_ID=${var.domain-node-config.domain-id[0]} >> /home/${var.ssh_user}/subspace/.env",
"echo RELAYER_SYSTEM_ID=$(sed -nr 's/NODE_${count.index}_RELAYER_SYSTEM_ID=//p' /home/${var.ssh_user}/subspace/relayer_ids.txt) >> /home/${var.ssh_user}/subspace/.env",
"echo RELAYER_DOMAIN_ID=$(sed -nr 's/NODE_${count.index}_RELAYER_DOMAIN_ID=//p' /home/${var.ssh_user}/subspace/relayer_ids.txt) >> /home/${var.ssh_user}/subspace/.env",
"echo DOMAIN_LABEL_EVM=${var.domain-node-config.domain-labels[0]} >> /home/${var.ssh_user}/subspace/.env",
"echo DOMAIN_ID_EVM=${var.domain-node-config.domain-id[0]} >> /home/${var.ssh_user}/subspace/.env",
"echo DOMAIN_LABEL_AUTO=${var.domain-node-config.domain-labels[1]} >> /home/${var.ssh_user}/subspace/.env",
"echo DOMAIN_ID_AUTO=${var.domain-node-config.domain-id[1]} >> /home/${var.ssh_user}/subspace/.env",
"echo NR_API_KEY=${var.nr_api_key} >> /home/${var.ssh_user}/subspace/.env",
"echo PIECE_CACHE_SIZE=${var.piece_cache_size} >> /home/${var.ssh_user}/subspace/.env",
"echo DSN_NODE_ID=${count.index} >> /home/${var.ssh_user}/subspace/.env",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ resource "null_resource" "start-domain-nodes" {
"echo NETWORK_NAME=${var.network_name} >> /home/${var.ssh_user}/subspace/.env",
"echo DOMAIN_PREFIX=${var.domain-node-config.domain-prefix} >> /home/${var.ssh_user}/subspace/.env",
# //todo use a map for domain id and labels
"echo DOMAIN_LABEL=${var.domain-node-config.domain-labels[0]} >> /home/${var.ssh_user}/subspace/.env",
"echo DOMAIN_ID=${var.domain-node-config.domain-id[0]} >> /home/${var.ssh_user}/subspace/.env",
"echo DOMAIN_LABEL_EVM=${var.domain-node-config.domain-labels[0]} >> /home/${var.ssh_user}/subspace/.env",
"echo DOMAIN_ID_EVM=${var.domain-node-config.domain-id[0]} >> /home/${var.ssh_user}/subspace/.env",
"echo DOMAIN_LABEL_AUTO=${var.domain-node-config.domain-labels[1]} >> /home/${var.ssh_user}/subspace/.env",
"echo DOMAIN_ID_AUTO=${var.domain-node-config.domain-id[1]} >> /home/${var.ssh_user}/subspace/.env",
"echo NODE_ID=${count.index} >> /home/${var.ssh_user}/subspace/.env",
"echo NODE_KEY=$(sed -nr 's/NODE_${count.index}_KEY=//p' /home/${var.ssh_user}/subspace/node_keys.txt) >> /home/${var.ssh_user}/subspace/.env",
"echo RELAYER_SYSTEM_ID=$(sed -nr 's/NODE_${count.index}_RELAYER_SYSTEM_ID=//p' /home/${var.ssh_user}/subspace/relayer_ids.txt) >> /home/${var.ssh_user}/subspace/.env",
"echo RELAYER_DOMAIN_ID=$(sed -nr 's/NODE_${count.index}_RELAYER_DOMAIN_ID=//p' /home/${var.ssh_user}/subspace/relayer_ids.txt) >> /home/${var.ssh_user}/subspace/.env",
"echo NR_API_KEY=${var.nr_api_key} >> /home/${var.ssh_user}/subspace/.env",
"echo PIECE_CACHE_SIZE=${var.piece_cache_size} >> /home/${var.ssh_user}/subspace/.env",
"echo NODE_DSN_PORT=${var.domain-node-config.node-dsn-port} >> /home/${var.ssh_user}/subspace/.env",
Expand Down

0 comments on commit 3d73464

Please sign in to comment.