Skip to content

Commit

Permalink
Merge pull request #14576 from MinaProtocol/steven-berkeley-terraform…
Browse files Browse the repository at this point in the history
…-repair

repairing berkeley testnet module compatibility
  • Loading branch information
stevenplatt authored Nov 30, 2023
2 parents 03644c5 + 67b0ad4 commit 0692fa8
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 157 deletions.
65 changes: 31 additions & 34 deletions automation/terraform/modules/kubernetes/testnet/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,13 @@ variable "seed_external_port" {
variable "seed_configs" {
type = list(
object({
name = string,
class = string,
libp2p_secret = string,
libp2p_secret_pw = string
# external_port = number,
external_ip = string,
# private_key_secret = string,
enableArchive = bool,
archiveAddress = string
name = string,
class = string,
libp2p_secret = string,
libp2p_secret_pw = string
external_ip = string,
enableArchive = bool,
archiveAddress = string
persist_working_dir = bool,
})
)
Expand All @@ -225,19 +223,18 @@ variable "log_level" {
default = "Trace"
}

# variable "block_producer_key_pass" {
# type = string
# }
variable "block_producer_key_pass" {
type = string
default = "naughty blue worm"
}

variable "block_producer_configs" {
type = list(
object({
name = string,
class = string,
keypair_name = string,
# private_key = string,
# public_key = string,
privkey_password = string,
keypair_name = string,
privkey_password = string,
external_port = number,
libp2p_secret = string,
enable_gossip_flooding = bool,
Expand All @@ -259,16 +256,16 @@ variable "plain_node_configs" {

# Snark Worker Vars
variable "snark_coordinators" {
type = list(
type = list(
object({

snark_coordinator_name = string,
snark_worker_replicas = number
snark_worker_fee = number
snark_worker_public_key = string
snark_coordinator_name = string
snark_worker_replicas = number
snark_worker_fee = number
snark_worker_public_key = string
snark_coordinators_host_port = number
persist_working_dir = bool
}))
persist_working_dir = bool
}))
default = []
}

Expand Down Expand Up @@ -354,17 +351,17 @@ variable "make_report_accounts" {
variable "archive_configs" {
type = list(
object({
name = string
image = string
serverPort = string
externalPort = string
enableLocalDaemon = bool
enablePostgresDB = bool

postgresHost = string
postgresPort = string
remoteSchemaFile = string
remoteSchemaAuxFiles = list(string)
name = string
image = string
serverPort = string
externalPort = string
enableLocalDaemon = bool
enablePostgresDB = bool

postgresHost = string
postgresPort = string
remoteSchemaFile = string
remoteSchemaAuxFiles = list(string)

persistenceEnabled = bool
persistenceSize = string
Expand Down
31 changes: 18 additions & 13 deletions automation/terraform/modules/o1-testnet/inputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,25 @@ variable "seed_discovery_keypairs" {
]
}

variable "seed_external_port" {
type = string
default = "10001"
}

# Block Producer Vars

variable "whales" {
description = "individual whale block producer node deployment configurations"
default = null
default = null
}

variable "fishes" {
description = "individual fish block producer node deployment configurations"
default = null
default = null
}

variable "nodes_with_user_agent" {
type = list(string)
type = list(string)
default = []
}

Expand Down Expand Up @@ -186,15 +191,15 @@ variable "seed_starting_host_port" {

variable "snark_coordinators" {
description = "configurations for not just the snark coordinators but also the snark workers they coordinate"
type = list(
type = list(
object({

snark_coordinator_name = string,
snark_worker_replicas = number
snark_worker_fee = number
snark_worker_public_key = string
snark_coordinator_name = string,
snark_worker_replicas = number
snark_worker_fee = number
snark_worker_public_key = string
snark_coordinators_host_port = number
}))
persist_working_dir = bool
}))
default = []
}

Expand Down Expand Up @@ -266,7 +271,7 @@ variable "make_report_accounts" {
}

variable "log_precomputed_blocks" {
type = bool
type = bool
default = false
}

Expand Down Expand Up @@ -299,7 +304,7 @@ variable "archive_node_count" {

variable "archive_configs" {
description = "individual archive-node deployment configurations"
default = null
default = null
}

variable "upload_blocks_to_gcloud" {
Expand All @@ -315,4 +320,4 @@ variable "seed_peers_url" {
variable "zkapps_dashboard_key" {
type = string
default = ""
}
}
115 changes: 58 additions & 57 deletions automation/terraform/modules/o1-testnet/locals.tf
Original file line number Diff line number Diff line change
@@ -1,101 +1,102 @@
locals {


whale_count_total = length ( flatten( [
whale_count_total = length(flatten([
for bp in var.whales :
[
for i in range(bp.duplicates) : ""

] ]) )
[
for i in range(bp.duplicates) : ""

fish_count_total = length ( flatten( [
]]))

fish_count_total = length(flatten([
for index, bp in var.fishes :
[
for i in range(bp.duplicates) : ""
] ]) )
[
for i in range(bp.duplicates) : ""

]]))



whale_block_producer_libp2p_names = [for i in range(local.whale_count_total) : "whale-block-producer-${i + 1}"]
fish_block_producer_libp2p_names = [for i in range(local.fish_count_total) : "fish-block-producer-${i + 1}"]


whale_configs = flatten( [
whale_configs = flatten([
for index, bp in var.whales :
[
for i in range(bp.duplicates) : {
name = "whale-${index+1}-${i+1}"
unique_node_index= index+1
total_node_index= 1+ i+ length ( flatten([for b in slice(var.whales,0, index) : [ for k in range(b.duplicates):0 ] ])) #summation of all duplicates so far
# full_peer = "/dns4/whale-${index+1}-${i+1}.${var.testnet_name}/tcp/${var.block_producer_starting_host_port +i+ length ( flatten([for b in slice(var.whales,0, index) : [ for k in range(b.duplicates):0 ] ]))}/p2p/${trimspace(data.local_file.libp2p_peers[element (local.whale_block_producer_libp2p_names,i+ length ( flatten([for b in slice(var.whales,0, index) : [ for k in range(b.duplicates):0 ] ])) ) ].content)}",
port = var.block_producer_starting_host_port+i + length ( flatten([for b in slice(var.whales,0, index) : [ for k in range(b.duplicates):"" ] ]))
class = "whale"

}
] ])

fish_configs = flatten( [
[
for i in range(bp.duplicates) : {
name = "whale-${index + 1}-${i + 1}"
unique_node_index = index + 1
total_node_index = 1 + i + length(flatten([for b in slice(var.whales, 0, index) : [for k in range(b.duplicates) : 0]])) #summation of all duplicates so far
# full_peer = "/dns4/whale-${index+1}-${i+1}.${var.testnet_name}/tcp/${var.block_producer_starting_host_port +i+ length ( flatten([for b in slice(var.whales,0, index) : [ for k in range(b.duplicates):0 ] ]))}/p2p/${trimspace(data.local_file.libp2p_peers[element (local.whale_block_producer_libp2p_names,i+ length ( flatten([for b in slice(var.whales,0, index) : [ for k in range(b.duplicates):0 ] ])) ) ].content)}",
port = var.block_producer_starting_host_port + i + length(flatten([for b in slice(var.whales, 0, index) : [for k in range(b.duplicates) : ""]]))
class = "whale"

}

]])

fish_configs = flatten([
for index, bp in var.fishes :
[
for i in range(bp.duplicates) : {
name = "fish-${index+1}-${i+1}"
unique_node_index= index+1
total_node_index= 1+ i+length ( flatten([for b in slice(var.fishes,0, index) : [ for k in range(b.duplicates):0 ] ]))
# full_peer = "/dns4/fish-${index+1}-${i+1}.${var.testnet_name}/tcp/${var.block_producer_starting_host_port +i+ length ( flatten([for b in slice(var.fishes,0, index) : [ for k in range(b.duplicates):0 ] ]))}/p2p/${trimspace(data.local_file.libp2p_peers[element (local.fish_block_producer_libp2p_names,i+ length ( flatten([for b in slice(var.fishes,0, index) : [ for k in range(b.duplicates):0 ] ])) ) ].content)}",
port = var.block_producer_starting_host_port+i + length ( flatten([for b in slice(var.fishes,0, index) : [ for k in range(b.duplicates):"" ] ]))
class = "fish"

}
] ])
[
for i in range(bp.duplicates) : {
name = "fish-${index + 1}-${i + 1}"
unique_node_index = index + 1
total_node_index = 1 + i + length(flatten([for b in slice(var.fishes, 0, index) : [for k in range(b.duplicates) : 0]]))
# full_peer = "/dns4/fish-${index+1}-${i+1}.${var.testnet_name}/tcp/${var.block_producer_starting_host_port +i+ length ( flatten([for b in slice(var.fishes,0, index) : [ for k in range(b.duplicates):0 ] ]))}/p2p/${trimspace(data.local_file.libp2p_peers[element (local.fish_block_producer_libp2p_names,i+ length ( flatten([for b in slice(var.fishes,0, index) : [ for k in range(b.duplicates):0 ] ])) ) ].content)}",
port = var.block_producer_starting_host_port + i + length(flatten([for b in slice(var.fishes, 0, index) : [for k in range(b.duplicates) : ""]]))
class = "fish"

}

]])

block_producer_configs = concat(local.whale_configs, local.fish_configs)

whale_count_unique = length(var.whales)
fish_count_unique = length(var.fishes)
fish_count_unique = length(var.fishes)

seed_names = [for i in range(var.seed_count) : "seed-${i + 1}"]
seed_names = [for i in range(var.seed_count) : "seed-${i + 1}"]

seed_static_peers = [
for index, name in keys(data.local_file.libp2p_seed_peers) : {
# i don't think the seeds need to have different ports
full_peer = "/dns4/${name}.${var.testnet_name}.o1test.net/tcp/${var.seed_external_port}/p2p/${trimspace(data.local_file.libp2p_seed_peers[name].content)}",
# port = var.seed_starting_host_port + index
name = local.seed_names[index]
unique_node_index= -1
total_node_index= -1
class = "seed"
name = local.seed_names[index]
unique_node_index = -1
total_node_index = -1
class = "seed"
}
]

default_archive_node = {
image = var.mina_archive_image
serverPort = "3086"
externalPort = "11010"
enableLocalDaemon = true
enablePostgresDB = true

postgresHost = "archive-1-postgresql"
postgresPort = 5432
image = var.mina_archive_image
serverPort = "3086"
externalPort = "11010"
enableLocalDaemon = true
enablePostgresDB = true

postgresHost = "archive-1-postgresql"
postgresPort = 5432
# remoteSchemaFile needs to be just the script name, not a url. remoteSchemaAuxFiles needs to be a list of urls of scripts, one of these urls needs to be the url of the main sql script that invokes the other ones. sorry it's confusing
remoteSchemaFile = var.mina_archive_schema
remoteSchemaAuxFiles = var.mina_archive_schema_aux_files
remoteSchemaFile = var.mina_archive_schema
remoteSchemaAuxFiles = var.mina_archive_schema_aux_files

persistenceEnabled = true
persistenceSize = "8Gi"
persistenceStorageClass = "ssd-delete"
persistenceAccessModes = ["ReadWriteOnce"]
spotAllowed = "false"
spotAllowed = "false"
persist_working_dir = true
}

static_peers = local.seed_static_peers

archive_node_configs = var.archive_configs != null ? [for item in var.archive_configs : merge(local.default_archive_node, item)] : [
for i in range(1, var.archive_node_count + 1) : merge(local.default_archive_node, {
name = "archive-${i}"
postgresHost = "archive-${i}-postgresql"
name = "archive-${i}"
postgresHost = "archive-${i}-postgresql"
})
]
}
Loading

0 comments on commit 0692fa8

Please sign in to comment.