Skip to content

Commit

Permalink
add rpc and nova squids infra terraform
Browse files Browse the repository at this point in the history
  • Loading branch information
DaMandal0rian committed Jul 18, 2024
1 parent 085bbb9 commit 0f4e1e1
Show file tree
Hide file tree
Showing 11 changed files with 426 additions and 184 deletions.
6 changes: 3 additions & 3 deletions resources/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Clone the repository and navigate to the testing framework directory **resources
│ ├── dns.tf
│ ├── domain_node_provisioner.tf
│ ├── farmer_node_provisioner.tf
│ ├── full_node_provisioner.tf
│ ├── rpc-squid_node_provisioner.tf
│ ├── instances.tf
│ ├── network.tf
│ ├── outputs.tf
Expand All @@ -64,7 +64,7 @@ Clone the repository and navigate to the testing framework directory **resources
│ │ ├── create_bootstrap_node_evm_compose_file.sh
│ │ ├── create_domain_node_compose_file.sh
│ │ ├── create_farmer_node_compose_file.sh
│ │ ├── create_full_node_compose_file.sh
│ │ ├── create_rpc-squid_node_compose_file.sh
│ │ ├── create_rpc_node_compose_file.sh
│ │ ├── installer.sh
│ │ └── prune_docker_system.sh
Expand Down Expand Up @@ -97,7 +97,7 @@ Each network will need it's own keys, which you can gather from bitwarden, and e
├── domain_node_keys.txt
├── dsn_bootstrap_node_keys.txt
├── farmer_node_keys.txt
├── full_node_keys.txt
├── rpc-squid_node_keys.txt
├── keystore
├── relayer_ids.txt
└── rpc_node_keys.txt
Expand Down
24 changes: 21 additions & 3 deletions resources/gemini-3h/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ module "gemini-3h" {
disk-volume-type = var.disk_volume_type
}

full-node-config = {
instance-type = var.instance_type["full"]
rpc-squid-node-config = {
instance-type = var.instance_type["rpc-squid"]
deployment-version = 0
regions = var.aws_region
instance-count = var.instance_count["full"]
instance-count = var.instance_count["rpc-squid"]
docker-org = "subspace"
docker-tag = "gemini-3h-2024-jul-16"
reserved-only = false
Expand All @@ -50,6 +50,24 @@ module "gemini-3h" {
disk-volume-type = var.disk_volume_type
}

domain-node-config = {
instance-type = var.instance_type["nova-squid"]
deployment-version = 0
regions = var.aws_region
instance-count = var.instance_count["nova-squid"]
docker-org = "subspace"
docker-tag = "gemini-3h-2024-jul-16"
domain-prefix = "nova-squid"
reserved-only = false
prune = false
node-dsn-port = 30433
enable-domains = true
domain-id = var.domain_id
domain-labels = var.domain_labels
disk-volume-size = var.disk_volume_size
disk-volume-type = var.disk_volume_type
}

rpc-node-config = {
instance-type = var.instance_type["rpc"]
deployment-version = 0
Expand Down
11 changes: 8 additions & 3 deletions resources/gemini-3h/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
//output
output "full-node-ipv4-addresses" {
value = module.gemini-3h.full_node_public_ip
description = "Full node IPv4 Addresses"
output "rpc-squid-node-ipv4-addresses" {
value = module.gemini-3h.rpc-squid_node_public_ip
description = "RPC squid node IPv4 Addresses"
}

output "nova-squid-node-ipv4-addresses" {
value = module.gemini-3h.nova-squid_node_public_ip
description = "Nova Squid node IPv4 Addresses"
}

output "farmer-node-ipv4-addresses" {
Expand Down
6 changes: 4 additions & 2 deletions resources/gemini-3h/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ variable "instance_type" {
bootstrap = "c7a.4xlarge"
rpc = "m6a.xlarge"
domain = "m6a.xlarge"
full = "c7a.2xlarge"
rpc-squid = "c7a.2xlarge"
nova-squid = "c7a.2xlarge"
farmer = "c7a.2xlarge"
evm_bootstrap = "c7a.xlarge"
}
Expand All @@ -56,7 +57,8 @@ variable "instance_count" {
bootstrap = 2
rpc = 2
domain = 2
full = 1
rpc-squid = 1
nova-squid = 1
farmer = 0
evm_bootstrap = 1
}
Expand Down
106 changes: 0 additions & 106 deletions templates/scripts/create_full_node_compose_file.sh

This file was deleted.

27 changes: 9 additions & 18 deletions templates/terraform/network-primitives/dns.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,20 @@ resource "cloudflare_record" "rpc" {
type = "A"
}

# Remove system domain
# resource "cloudflare_record" "system-domain" {
# count = length(local.domain_node_ip_v4)
# zone_id = data.cloudflare_zone.cloudflare_zone.id
# name = "${var.domain-node-config.domain-prefix}-${count.index}.system.${var.network_name}"
# value = local.domain_node_ip_v4[count.index]
# type = "A"
# }

resource "cloudflare_record" "core-domain" {
count = length(local.domain_nodes_ip_v4)
resource "cloudflare_record" "rpc-squid" {
count = length(local.rpc_squid_nodes_ip_v4)
zone_id = data.cloudflare_zone.cloudflare_zone.id
name = "${var.domain-node-config.domain-prefix}.${var.network_name}"
value = local.domain_nodes_ip_v4[count.index]
name = "${var.rpc-squid-node-config.domain-prefix}-${count.index}.${var.network_name}"
value = local.rpc_squid_nodes_ip_v4[count.index]
type = "A"
}

resource "cloudflare_record" "core-domain_ipv6" {
count = length(local.domain_nodes_ip_v4)
resource "cloudflare_record" "nova-squid-rpc" {
count = length(local.nova_squid_nodes_ip_v4)
zone_id = data.cloudflare_zone.cloudflare_zone.id
name = "${var.domain-node-config.domain-prefix}.${var.network_name}"
value = local.domain_nodes_ip_v6[count.index]
type = "AAAA"
name = "${var.nova-squid-node-config.domain-prefix}-${count.index}.${var.network_name}"
value = local.nova_squid_nodes_ip_v4[count.index]
type = "A"
}

resource "cloudflare_record" "nova" {
Expand Down
78 changes: 70 additions & 8 deletions templates/terraform/network-primitives/instances.tf
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ resource "aws_instance" "bootstrap_node_evm" {

}

resource "aws_instance" "full_node" {
count = length(var.aws_region) * var.full-node-config.instance-count
resource "aws_instance" "rpc_squid_node" {
count = length(var.aws_region) * var.rpc-squid-node-config.instance-count
ami = data.aws_ami.ubuntu_amd64.image_id
instance_type = var.full-node-config.instance-type
instance_type = var.rpc-squid-node-config.instance-type
subnet_id = element(aws_subnet.public_subnets.*.id, 0)
availability_zone = var.azs
ipv6_address_count = 1
Expand All @@ -141,16 +141,16 @@ resource "aws_instance" "full_node" {
ebs_optimized = true
ebs_block_device {
device_name = "/dev/sda1"
volume_size = var.full-node-config.disk-volume-size
volume_type = var.full-node-config.disk-volume-type
volume_size = var.rpc-squid-node-config.disk-volume-size
volume_type = var.rpc-squid-node-config.disk-volume-type
iops = 3000
throughput = 250
}

tags = {
Name = "${var.network_name}-full-${count.index}"
name = "${var.network_name}-full-${count.index}"
role = "full node"
Name = "${var.network_name}-rpc-squid-${count.index}"
name = "${var.network_name}-rpc-squid-${count.index}"
role = "rpc-squid node"
os_name = "ubuntu"
os_version = "22.04"
arch = "x86_64"
Expand Down Expand Up @@ -189,6 +189,68 @@ resource "aws_instance" "full_node" {

}

resource "aws_instance" "nova_squid_node" {
count = length(var.aws_region) * var.nova-squid-node-config.instance-count
ami = data.aws_ami.ubuntu_amd64.image_id
instance_type = var.nova-squid-node-config.instance-type
subnet_id = element(aws_subnet.public_subnets.*.id, 0)
availability_zone = var.azs
ipv6_address_count = 1
# Security Group
vpc_security_group_ids = ["${aws_security_group.network_sg.id}"]
# the Public SSH key
key_name = var.aws_key_name
associate_public_ip_address = true
ebs_optimized = true
ebs_block_device {
device_name = "/dev/sda1"
volume_size = var.nova-squid-node-config.disk-volume-size
volume_type = var.nova-squid-node-config.disk-volume-type
iops = 3000
throughput = 250
}

tags = {
Name = "${var.network_name}-nova-squid-${count.index}"
name = "${var.network_name}-nova-squid-${count.index}"
role = "nova-squid node"
os_name = "ubuntu"
os_version = "22.04"
arch = "x86_64"
}

depends_on = [
aws_subnet.public_subnets,
#aws_nat_gateway.nat_gateway,
aws_internet_gateway.gw
]

lifecycle {

ignore_changes = [ami, ipv6_address_count]

}

provisioner "remote-exec" {
inline = [
"cloud-init status --wait",
"sudo apt update -y",
]

on_failure = continue

}

# Setting up the ssh connection
connection {
type = "ssh"
host = element(self.*.public_ip, count.index)
user = var.ssh_user
private_key = file("${var.private_key_path}")
timeout = "300s"
}

}

resource "aws_instance" "rpc_node" {
count = length(var.aws_region) * var.rpc-node-config.instance-count
Expand Down
Loading

0 comments on commit 0f4e1e1

Please sign in to comment.