diff --git a/bootstrap/configs/vector-testnet/config.json b/bootstrap/configs/vector-testnet/config.json new file mode 100644 index 0000000..6136690 --- /dev/null +++ b/bootstrap/configs/vector-testnet/config.json @@ -0,0 +1,107 @@ +{ + "ByronGenesisFile": "/genesis/vector-testnet/byron.json", + "ShelleyGenesisFile": "/genesis/vector-testnet/shelley.json", + "AlonzoGenesisFile": "/genesis/vector-testnet/alonzo.json", + "ConwayGenesisFile": "/genesis/vector-testnet/conway.json", + "SocketPath": "db/node.socket", + "PBftSignatureThreshold": 0.6, + "MaxConcurrencyBulkSync": 1, + "MaxConcurrencyDeadline": 2, + "Protocol": "Cardano", + "RequiresNetworkMagic": "RequiresMagic", + "LastKnownBlockVersion-Major": 6, + "LastKnownBlockVersion-Minor": 0, + "LastKnownBlockVersion-Alt": 0, + "TurnOnLogging": true, + "TurnOnLogMetrics": true, + "minSeverity": "Debug", + "TracingVerbosity": "NormalVerbosity", + "setupBackends": ["KatipBK"], + "defaultBackends": ["KatipBK"], + "hasEKG": 12788, + "hasPrometheus": [ + "0.0.0.0", + 12798 + ], + "setupScribes": [ + { + "scKind": "FileSK", + "scName": "logs/mainnet.log", + "scFormat": "ScText" + }, + { + "scKind": "StdoutSK", + "scName": "stdout", + "scFormat": "ScText" + } + ], + "defaultScribes": [ + ["FileSK", "logs/mainnet.log"], + ["StdoutSK", "stdout"] + ], + "rotation": { + "rpLogLimitBytes": 5000000, + "rpKeepFilesNum": 3, + "rpMaxAgeHours": 24 + }, + "TraceBlockFetchClient": false, + "TraceBlockFetchDecisions": false, + "TraceBlockFetchProtocol": false, + "TraceBlockFetchProtocolSerialised": false, + "TraceBlockFetchServer": false, + "TraceBlockchainTime": false, + "TraceChainDb": true, + "TraceChainSyncClient": false, + "TraceChainSyncBlockServer": false, + "TraceChainSyncHeaderServer": false, + "TraceChainSyncProtocol": false, + "TraceDNSResolver": true, + "TraceDNSSubscription": true, + "TraceErrorPolicy": true, + "TraceLocalErrorPolicy": true, + "TraceForge": true, + "TraceHandshake": false, + "TraceIpSubscription": true, + "TraceLocalRootPeers": true, + "TracePublicRootPeers": true, + "TracePeerSelection": true, + "TraceDebugPeerSelection": false, + "TracePeerSelectionActions": true, + "TraceConnectionManager": true, + "TraceServer": true, + "TraceLocalConnectionManager": false, + "TraceLocalServer": false, + "TraceLocalChainSyncProtocol": false, + "TraceLocalHandshake": false, + "TraceLocalTxSubmissionProtocol": false, + "TraceLocalTxSubmissionServer": false, + "TraceMempool": true, + "TraceMux": false, + "TraceTxInbound": false, + "TraceTxOutbound": false, + "TraceTxSubmissionProtocol": false, + "options": { + "mapBackends": { + "cardano.node.metrics": ["EKGViewBK"] + }, + "mapScribes": { + "cardano.node.metrics": ["FileSK::logs/mainnet.log"] + }, + "mapSeverity": { + "cardano.node.ChainDB": "Notice", + "cardano.node.DnsSubscription": "Debug" + } + }, + "TestShelleyHardForkAtEpoch": 0, + "TestAllegraHardForkAtEpoch": 0, + "TestMaryHardForkAtEpoch": 0, + "TestAlonzoHardForkAtEpoch": 0, + "TestBabbageHardForkAtEpoch": 0, + "ExperimentalProtocolsEnabled": true, + "ApplicationName":"cardano-sl", + "ApplicationVersion":0, + "ByronGenesisHash":"abc5e260bf7c5d7008eab849705fc0eae911b638dd6687b1f10cef2e2bc8a713", + "ShelleyGenesisHash":"fb2ca1cc879a9a7600103c2170c9d58e366cd77e17edf39a0e7bc1504f573e88", + "AlonzoGenesisHash":"1cd94b66eade0670885744a858accdb2c3249e43e247db2c66b158050ec6a3e4", + "ConwayGenesisHash":"d43d3f38e01848bddf67e66fe29fbd236aca252de58c7f2c1904c67107c17842" +} diff --git a/bootstrap/configs/vector-testnet/db-sync-config.json b/bootstrap/configs/vector-testnet/db-sync-config.json new file mode 100644 index 0000000..e63da69 --- /dev/null +++ b/bootstrap/configs/vector-testnet/db-sync-config.json @@ -0,0 +1,116 @@ +{ + "EnableLogMetrics":false, + "EnableLogging":true, + "NetworkName":"testnet", + "NodeConfigFile":"config.json", + "PrometheusPort":8080, + "RequiresNetworkMagic":"RequiresMagic", + "defaultBackends":[ + "KatipBK" + ], + "defaultScribes":[ + [ + "StdoutSK", + "stdout" + ] + ], + "minSeverity":"Info", + "options":{ + "cfokey":{ + "value":"Release-1.0.0" + }, + "mapBackends":{ + + }, + "mapSeverity":{ + "db-sync-node":"Info", + "db-sync-node.Mux":"Error", + "db-sync-node.Subscription":"Error" + }, + "mapSubtrace":{ + "#ekgview":{ + "contents":[ + [ + { + "contents":"cardano.epoch-validation.benchmark", + "tag":"Contains" + }, + [ + { + "contents":".monoclock.basic.", + "tag":"Contains" + } + ] + ], + [ + { + "contents":"cardano.epoch-validation.benchmark", + "tag":"Contains" + }, + [ + { + "contents":"diff.RTS.cpuNs.timed.", + "tag":"Contains" + } + ] + ], + [ + { + "contents":"#ekgview.#aggregation.cardano.epoch-validation.benchmark", + "tag":"StartsWith" + }, + [ + { + "contents":"diff.RTS.gcNum.timed.", + "tag":"Contains" + } + ] + ] + ], + "subtrace":"FilterTrace" + }, + "#messagecounters.aggregation":{ + "subtrace":"NoTrace" + }, + "#messagecounters.ekgview":{ + "subtrace":"NoTrace" + }, + "#messagecounters.katip":{ + "subtrace":"NoTrace" + }, + "#messagecounters.monitoring":{ + "subtrace":"NoTrace" + }, + "#messagecounters.switchboard":{ + "subtrace":"NoTrace" + }, + "benchmark":{ + "contents":[ + "GhcRtsStats", + "MonotonicClock" + ], + "subtrace":"ObservableTrace" + }, + "cardano.epoch-validation.utxo-stats":{ + "subtrace":"NoTrace" + } + } + }, + "rotation":{ + "rpKeepFilesNum":10, + "rpLogLimitBytes":5000000, + "rpMaxAgeHours":24 + }, + "setupBackends":[ + "AggregationBK", + "KatipBK" + ], + "setupScribes":[ + { + "scFormat":"ScText", + "scKind":"StdoutSK", + "scName":"stdout", + "scRotation":null + } + ] +} \ No newline at end of file diff --git a/bootstrap/feature/configs.tf b/bootstrap/feature/configs.tf index 7d0df98..5d81058 100644 --- a/bootstrap/feature/configs.tf +++ b/bootstrap/feature/configs.tf @@ -6,6 +6,6 @@ resource "kubernetes_config_map" "pgbouncer_certs" { data = { "server.crt" = var.pgbouncer_server_crt - "key.crt" = var.pgbouncer_server_key + "server.key" = var.pgbouncer_server_key } } diff --git a/bootstrap/feature/main.tf b/bootstrap/feature/main.tf index d2ee5ea..24199ef 100644 --- a/bootstrap/feature/main.tf +++ b/bootstrap/feature/main.tf @@ -23,12 +23,9 @@ variable "dcu_per_second" { } } -variable "postgres_host_1" { - type = string -} -variable "postgres_host_2" { - type = string +variable "postgres_hosts" { + type = list(string) } variable "postgres_secret_name" { @@ -45,4 +42,4 @@ variable "pgbouncer_server_crt" { variable "pgbouncer_server_key" { type = string -} \ No newline at end of file +} diff --git a/bootstrap/feature/operator.tf b/bootstrap/feature/operator.tf index 166dc72..c1adf55 100644 --- a/bootstrap/feature/operator.tf +++ b/bootstrap/feature/operator.tf @@ -1,3 +1,8 @@ +locals { + postgres_urls = [for host in var.postgres_hosts : "postgres://postgres:$(POSTGRES_PASSWORD)@${host}:5432"] + combined_postgres_urls = join(",", local.postgres_urls) +} + resource "kubernetes_deployment_v1" "operator" { wait_for_rollout = false @@ -57,17 +62,17 @@ resource "kubernetes_deployment_v1" "operator" { env { name = "DCU_PER_SECOND" - value = "mainnet=${var.dcu_per_second["mainnet"]},preprod=${var.dcu_per_second["preprod"]},preview=${var.dcu_per_second["preview"]}" + value = "mainnet=${var.dcu_per_second["mainnet"]},preprod=${var.dcu_per_second["preprod"]},preview=${var.dcu_per_second["preview"]},vector-testnet=${var.dcu_per_second["vector-testnet"]}" } env { name = "DB_URLS" - value = "postgres://postgres:$(POSTGRES_PASSWORD)@${var.postgres_host_1}:5432,postgres://postgres:$(POSTGRES_PASSWORD)@${var.postgres_host_2}:5432" + value = local.combined_postgres_urls } env { name = "DB_NAMES" - value = "mainnet=dbsync-mainnet,preprod=dbsync-preprod,preview=dbsync-preview" + value = "mainnet=dbsync-mainnet,preprod=dbsync-preprod,preview=dbsync-preview,vector-testnet=dbsync-vector-testnet" } env { diff --git a/bootstrap/pgbouncer/pgbouncer.ini.tftpl b/bootstrap/pgbouncer/pgbouncer.ini.tftpl index 0c4995e..5387dd0 100644 --- a/bootstrap/pgbouncer/pgbouncer.ini.tftpl +++ b/bootstrap/pgbouncer/pgbouncer.ini.tftpl @@ -1,8 +1,8 @@ [databases] *=host=${db_host} port=5432 auth_user=pgbouncer -mainnet=host=${db_host} port=5432 dbname=dbsync-mainnet auth_user=pgbouncer -preview=host=${db_host} port=5432 dbname=dbsync-preview auth_user=pgbouncer -preprod=host=${db_host} port=5432 dbname=dbsync-preprod auth_user=pgbouncer +dbsync-mainnet=host=${db_host} port=5432 dbname=dbsync-mainnet auth_user=pgbouncer pool_size=60 max_db_connections=70 +dbsync-preview=host=${db_host} port=5432 dbname=dbsync-preview auth_user=pgbouncer max_db_connections=10 +dbsync-preprod=host=${db_host} port=5432 dbname=dbsync-preprod auth_user=pgbouncer max_db_connections=10 cardanodbsync=host=${db_host} port=5432 dbname=dbsync-mainnet auth_user=pgbouncer [pgbouncer] @@ -27,7 +27,7 @@ tcp_keepcnt=9 tcp_keepidle=300 tcp_keepintvl=75 admin_users=pgbouncer -max_db_connections=40 +max_db_connections=80 [users] %{ for user in users ~} ${user.name} = max_user_connections=${user.max_connections} diff --git a/scripts/reload-pgbouncer-configs.sh b/scripts/reload-pgbouncer-configs.sh new file mode 100644 index 0000000..71fa88c --- /dev/null +++ b/scripts/reload-pgbouncer-configs.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +echo "updating pgbouncer userlist.txt" +# Combine the files and sort them +cat /etc/pgbouncer/users.txt /opt/bitnami/pgbouncer/conf/userlist.txt | sort > combined_sorted.txt + +# Use awk to remove duplicates, keeping the last occurrence +awk '!seen[$1]++' combined_sorted.txt > /opt/bitnami/pgbouncer/conf/userlist.txt + +# Clean up intermediate file +rm combined_sorted.txt + +echo "updating pgbouncer.ini" + +cp /bitnami/pgbouncer/conf/pgbouncer.ini /opt/bitnami/pgbouncer/conf/pgbouncer.ini + +echo "reloading pgbouncer" + +psql -p 6432 -U pgbouncer -c "RELOAD" pgbouncer