From 15bb812b3e6822f7879bbabf0475b5aecc9b86e8 Mon Sep 17 00:00:00 2001 From: Marketen Date: Tue, 10 Dec 2024 21:58:14 +0100 Subject: [PATCH 1/6] overall fixes --- README.md | 2 +- docker-compose.yml | 6 +++--- metrics/Dockerfile | 1 - .../gnosis/{vmagent_template.yml => vmagent.yml} | 14 ++++++++++---- metrics/entrypoint.sh | 7 ------- shutter/Dockerfile | 4 ++-- shutter/go-shutter-settings/settings/keyper.go | 10 +++++----- shutter/scripts/configure_keyper.sh | 2 +- 8 files changed, 22 insertions(+), 24 deletions(-) rename metrics/config/gnosis/{vmagent_template.yml => vmagent.yml} (55%) diff --git a/README.md b/README.md index ce6770d..c484b64 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ This package includes the following services: - Uses VictoriaMetrics to send performance metrics to a remote Pushgateway. - - Configuration is handled through templates in `/config/gnosis/`, and the main config file (`vmagent.yml`) is dynamically generated based on environment variables. + - Configuration is handled via the config file `/config/gnosis/vmagent.yml`, placehoders in that file are automatically picked up from the environment by vmagent. ### Configuration diff --git a/docker-compose.yml b/docker-compose.yml index 494d9ec..2fd5560 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,8 +13,8 @@ services: build: context: shutter args: - ASSETS_VERSION: shutter-gnosis-1000-set-1v2 # $NETWORK-10*$CHAIN_ID-set-$VERSION - UPSTREAM_VERSION: gnosis-v1.2.4b1 + ASSETS_VERSION: shutter-gnosis-1000-set1.3 # $NETWORK-10*$CHAIN_ID-set-$VERSION + UPSTREAM_VERSION: v1.2.5 KEYPER_CONFIG_DIR: /keyper/config SHUTTER_CHAIN_DIR: /chain STAKER_SCRIPTS_VERSION: v0.1.0 @@ -31,7 +31,7 @@ services: build: context: metrics args: - ASSETS_VERSION: shutter-gnosis-1000-set-1v2 # $NETWORK-10*$CHAIN_ID-set-$VERSION + ASSETS_VERSION: shutter-gnosis-1000-set1.3 # $NETWORK-10*$CHAIN_ID-set-$VERSION restart: on-failure environment: SHUTTER_PUSH_METRICS_ENABLED: false diff --git a/metrics/Dockerfile b/metrics/Dockerfile index 89d1b3e..a504f05 100644 --- a/metrics/Dockerfile +++ b/metrics/Dockerfile @@ -9,7 +9,6 @@ FROM victoriametrics/vmagent:v1.101.0 ARG NETWORK ENV ASSETS_DIR=/assets \ - TEMPLATE_CONFIG_FILE=/config/${NETWORK}/vmagent_template.yml \ CONFIG_FILE=/config/${NETWORK}/vmagent.yml \ USER_SETTINGS_FILE=/config/user/settings.env diff --git a/metrics/config/gnosis/vmagent_template.yml b/metrics/config/gnosis/vmagent.yml similarity index 55% rename from metrics/config/gnosis/vmagent_template.yml rename to metrics/config/gnosis/vmagent.yml index 93c87bc..0dfb031 100644 --- a/metrics/config/gnosis/vmagent_template.yml +++ b/metrics/config/gnosis/vmagent.yml @@ -6,18 +6,24 @@ scrape_configs: static_configs: - targets: ["shutter.shutter-gnosis.dappnode:9100"] labels: - instance: "%{KEYPER_NAME}" + instance: "kpr-%{KEYPER_NAME}" deployment: "%{_ASSETS_VERSION}" + deployment_type: "dappnode" + network: "%{_ASSETS_NETWORK}" - job_name: 'shuttermint' metrics_path: / static_configs: - targets: ["shutter.shutter-gnosis.dappnode:26660"] labels: - instance: "%{KEYPER_NAME}" + instance: "kpr-%{KEYPER_NAME}" deployment: "%{_ASSETS_VERSION}" + deployment_type: "dappnode" + network: "%{_ASSETS_NETWORK}" - job_name: 'vmagent' static_configs: - targets: ["localhost:8429"] labels: - instance: "%{KEYPER_NAME}" - deployment: "%{_ASSETS_VERSION}" \ No newline at end of file + instance: "kpr-%{KEYPER_NAME}" + deployment: "%{_ASSETS_VERSION}" + deployment_type: "dappnode" + network: "%{_ASSETS_NETWORK}" \ No newline at end of file diff --git a/metrics/entrypoint.sh b/metrics/entrypoint.sh index d9284e1..2eb9f9c 100755 --- a/metrics/entrypoint.sh +++ b/metrics/entrypoint.sh @@ -62,11 +62,6 @@ source_user_settings() { fi } -replace_envs_in_yaml() { - echo "[INFO | metrics] Replacing environment variables in the configuration file" - sed "s|%{KEYPER_NAME}|$KEYPER_NAME|g; s|%{_ASSETS_VERSION}|$_ASSETS_VERSION|g" "$TEMPLATE_CONFIG_FILE" >"$CONFIG_FILE" -} - update_user_settings if [ "${SHUTTER_PUSH_METRICS_ENABLED}" = "false" ]; then @@ -78,8 +73,6 @@ source_assets_envs source_user_settings -replace_envs_in_yaml - exec /vmagent-prod \ -promscrape.config="${CONFIG_FILE}" \ -remoteWrite.url="${PUSHGATEWAY_URL}" \ diff --git a/shutter/Dockerfile b/shutter/Dockerfile index 5d86603..d3afb80 100644 --- a/shutter/Dockerfile +++ b/shutter/Dockerfile @@ -6,7 +6,7 @@ FROM ghcr.io/shutter-network/assets:${ASSETS_VERSION} as assets RUN rsync -aq --delete /assets-source/ /assets/ ARG UPSTREAM_VERSION -FROM ghcr.io/shutter-network/rolling-shutter:${UPSTREAM_VERSION} +FROM ghcr.io/shutter-network/keyper:${UPSTREAM_VERSION} ARG NETWORK ARG KEYPER_CONFIG_DIR @@ -23,7 +23,7 @@ RUN apt-get update && \ ENV SHUTTER_GNOSIS_SM_BLOCKTIME=10 \ SHUTTER_GNOSIS_GENESIS_KEYPER=0x440Dc6F164e9241F04d282215ceF2780cd0B755e \ SHUTTER_GNOSIS_MAXTXPOINTERAGE=5 \ - SHUTTER_DATABASE_URL=postgres://postgres@db.shutter-${NETWORK}.dappnode:5432/keyper \ + SHUTTER_DATABASEURL=postgres://postgres@db.shutter-${NETWORK}.dappnode:5432/keyper \ SHUTTER_SHUTTERMINT_SHUTTERMINTURL=http://localhost:26657 \ CHAIN_LISTEN_PORT=26657 \ SHUTTER_BIN=/rolling-shutter \ diff --git a/shutter/go-shutter-settings/settings/keyper.go b/shutter/go-shutter-settings/settings/keyper.go index a0310be..0970ffc 100644 --- a/shutter/go-shutter-settings/settings/keyper.go +++ b/shutter/go-shutter-settings/settings/keyper.go @@ -8,7 +8,7 @@ import ( type KeyperConfig struct { InstanceID int `env:"_ASSETS_INSTANCE_ID"` - DatabaseURL string `env:"SHUTTER_DATABASE_URL"` + DatabaseURL string `env:"SHUTTER_DATABASEURL"` BeaconAPIURL string `env:"SHUTTER_BEACONAPIURL"` MaxNumKeysPerMessage int `env:"_ASSETS_MAX_NUM_KEYS_PER_MESSAGE"` Gnosis struct { @@ -31,8 +31,8 @@ type KeyperConfig struct { } P2P struct { P2PKey string `env:"SHUTTER_P2P_KEY"` - ListenAddresses string `env:"SHUTTER_P2P_LISTENADDRESSES"` - AdvertiseAddresses string `env:"SHUTTER_P2P_ADVERTISEADDRESSES"` + ListenAddresses []string `env:"SHUTTER_P2P_LISTENADDRESSES"` + AdvertiseAddresses []string `env:"SHUTTER_P2P_ADVERTISEADDRESSES"` CustomBootstrapAddresses []string `env:"_ASSETS_CUSTOM_BOOTSTRAP_ADDRESSES"` DiscoveryNamespace string `env:"_ASSETS_DISCOVERY_NAME_PREFIX"` } @@ -44,7 +44,7 @@ type KeyperConfig struct { DKGStartBlockDelta int `env:"_ASSETS_DKG_START_BLOCK_DELTA"` } Metrics struct { - Enabled bool `env:"SHUTTER_ENABLED"` + Enabled bool `env:"SHUTTER_METRICS_ENABLED"` } } @@ -82,4 +82,4 @@ func AddSettingsToKeyper(generatedFilePath, configFilePath, outputFilePath strin fmt.Println("Keyper TOML file modified successfully and saved to", outputFilePath) return nil -} \ No newline at end of file +} diff --git a/shutter/scripts/configure_keyper.sh b/shutter/scripts/configure_keyper.sh index fecaf01..7c4c771 100755 --- a/shutter/scripts/configure_keyper.sh +++ b/shutter/scripts/configure_keyper.sh @@ -10,7 +10,7 @@ echo "[INFO | configure] Calculating keyper configuration values..." SUPPORTED_NETWORKS="gnosis" -export SHUTTER_P2P_ADVERTISEADDRESSES="/ip4/${_DAPPNODE_GLOBAL_PUBLIC_IP}/tcp/${KEYPER_PORT}" +export SHUTTER_P2P_ADVERTISEADDRESSES="[\"/ip4/${_DAPPNODE_GLOBAL_PUBLIC_IP}/tcp/${KEYPER_PORT}\"]" export SHUTTER_BEACONAPIURL=$(get_beacon_api_url_from_global_env "$NETWORK" "$SUPPORTED_NETWORKS") export SHUTTER_GNOSIS_NODE_CONTRACTSURL=http://execution.gnosis.dncore.dappnode:8545 export SHUTTER_GNOSIS_NODE_ETHEREUMURL=$(get_execution_ws_url_from_global_env "$NETWORK" "$SUPPORTED_NETWORKS") From 854f26f418d6edca2c0852d683dcd17e038ab1a6 Mon Sep 17 00:00:00 2001 From: Marketen Date: Tue, 10 Dec 2024 22:22:12 +0100 Subject: [PATCH 2/6] configure keyper before db init --- shutter/scripts/configure.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shutter/scripts/configure.sh b/shutter/scripts/configure.sh index d62aa04..1f0f305 100755 --- a/shutter/scripts/configure.sh +++ b/shutter/scripts/configure.sh @@ -31,7 +31,7 @@ init_keyper_db() { echo "[INFO | configure] Initializing keyper database..." - $SHUTTER_BIN gnosiskeyper initdb --config "$KEYPER_GENERATED_CONFIG_FILE" + $SHUTTER_BIN gnosiskeyper initdb --config "$KEYPER_CONFIG_FILE" } init_chain() { @@ -73,12 +73,12 @@ check_assets generate_keyper_config +configure_keyper + init_keyper_db init_chain -configure_keyper - configure_chain trigger_chain_start From 83075068c1e60136ed78bfccab6e5612814dbb64 Mon Sep 17 00:00:00 2001 From: Marketen Date: Tue, 10 Dec 2024 22:38:57 +0100 Subject: [PATCH 3/6] change order & use generated for db init --- shutter/scripts/configure.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shutter/scripts/configure.sh b/shutter/scripts/configure.sh index 1f0f305..dbb79d4 100755 --- a/shutter/scripts/configure.sh +++ b/shutter/scripts/configure.sh @@ -31,7 +31,7 @@ init_keyper_db() { echo "[INFO | configure] Initializing keyper database..." - $SHUTTER_BIN gnosiskeyper initdb --config "$KEYPER_CONFIG_FILE" + $SHUTTER_BIN gnosiskeyper initdb --config "$KEYPER_GENERATED_CONFIG_FILE" } init_chain() { @@ -73,10 +73,10 @@ check_assets generate_keyper_config -configure_keyper - init_keyper_db +configure_keyper + init_chain configure_chain From b83042981e541ba567e07a73a402c97271239803 Mon Sep 17 00:00:00 2001 From: Marketen Date: Tue, 10 Dec 2024 23:23:27 +0100 Subject: [PATCH 4/6] add metrics env --- shutter/scripts/configure_keyper.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/shutter/scripts/configure_keyper.sh b/shutter/scripts/configure_keyper.sh index 7c4c771..a20e28a 100755 --- a/shutter/scripts/configure_keyper.sh +++ b/shutter/scripts/configure_keyper.sh @@ -15,6 +15,7 @@ export SHUTTER_BEACONAPIURL=$(get_beacon_api_url_from_global_env "$NETWORK" "$SU export SHUTTER_GNOSIS_NODE_CONTRACTSURL=http://execution.gnosis.dncore.dappnode:8545 export SHUTTER_GNOSIS_NODE_ETHEREUMURL=$(get_execution_ws_url_from_global_env "$NETWORK" "$SUPPORTED_NETWORKS") export VALIDATOR_PUBLIC_KEY=$(cat "${SHUTTER_CHAIN_DIR}/config/priv_validator_pubkey.hex") +export SHUTTER_METRICS_ENABLED=${SHUTTER_PUSH_METRICS_ENABLED} echo "[INFO | configure] LISTEN: $SHUTTER_P2P_LISTENADDRESSES" From 1320ab91b9accd55df4f0f504e68ac6d1c39fc76 Mon Sep 17 00:00:00 2001 From: Marketen Date: Wed, 11 Dec 2024 00:35:54 +0100 Subject: [PATCH 5/6] add listenaddress --- shutter/Dockerfile | 2 +- shutter/scripts/configure_keyper.sh | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/shutter/Dockerfile b/shutter/Dockerfile index d3afb80..c7784c9 100644 --- a/shutter/Dockerfile +++ b/shutter/Dockerfile @@ -52,7 +52,7 @@ COPY --from=assets ${ASSETS_DIR}/ ${ASSETS_DIR}/ # Placed here to rebuild less layers ENV CHAIN_PORT=${CHAIN_PORT} \ - SHUTTER_P2P_LISTENADDRESSES="/ip4/0.0.0.0/tcp/${KEYPER_PORT}" \ + SHUTTER_P2P_LISTENADDRESSES="/ip4/0.0.0.0/tcp/${KEYPER_PORT},/ip4/0.0.0.0/udp/${KEYPER_PORT}/quic-v1" \ NETWORK=${NETWORK} ENTRYPOINT ["supervisord", "-c", "/etc/supervisord.conf"] \ No newline at end of file diff --git a/shutter/scripts/configure_keyper.sh b/shutter/scripts/configure_keyper.sh index a20e28a..b5c6e81 100755 --- a/shutter/scripts/configure_keyper.sh +++ b/shutter/scripts/configure_keyper.sh @@ -10,7 +10,12 @@ echo "[INFO | configure] Calculating keyper configuration values..." SUPPORTED_NETWORKS="gnosis" -export SHUTTER_P2P_ADVERTISEADDRESSES="[\"/ip4/${_DAPPNODE_GLOBAL_PUBLIC_IP}/tcp/${KEYPER_PORT}\"]" +# Conditionally add square brackets to SHUTTER_P2P_LISTENADDRESSES +if [[ ! "$SHUTTER_P2P_LISTENADDRESSES" =~ ^\[.*\]$ ]]; then + export SHUTTER_P2P_LISTENADDRESSES="[$SHUTTER_P2P_LISTENADDRESSES]" +fi + +export SHUTTER_P2P_ADVERTISEADDRESSES="[\"/ip4/${_DAPPNODE_GLOBAL_PUBLIC_IP}/tcp/${KEYPER_PORT}\", \"/ip4/${_DAPPNODE_GLOBAL_PUBLIC_IP}/udp/${KEYPER_PORT}/quic-v1\"]" export SHUTTER_BEACONAPIURL=$(get_beacon_api_url_from_global_env "$NETWORK" "$SUPPORTED_NETWORKS") export SHUTTER_GNOSIS_NODE_CONTRACTSURL=http://execution.gnosis.dncore.dappnode:8545 export SHUTTER_GNOSIS_NODE_ETHEREUMURL=$(get_execution_ws_url_from_global_env "$NETWORK" "$SUPPORTED_NETWORKS") From c424562d71f9b80286aa7cd642c5e29fe7635b32 Mon Sep 17 00:00:00 2001 From: Marketen Date: Wed, 11 Dec 2024 02:01:13 +0100 Subject: [PATCH 6/6] fix ports --- package_variants/gnosis/docker-compose.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/package_variants/gnosis/docker-compose.yml b/package_variants/gnosis/docker-compose.yml index e1dbd69..fadfabf 100644 --- a/package_variants/gnosis/docker-compose.yml +++ b/package_variants/gnosis/docker-compose.yml @@ -6,14 +6,13 @@ services: CHAIN_PORT: 26656 KEYPER_PORT: 23003 KEYPER_METRICS_PORT: 9100 + ports: + - "23003:23003" + - "26656:26656" + - "26660:26660" + - "9100:9100" metrics: build: args: NETWORK: gnosis - - ports: - - "23003:23003/tcp" - - "26656:26656" - - "26660:26660" - - "9100:9100"