Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions crates/ciphernode-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#!/bin/bash
set -e

# Paths to config and secrets
CONFIG_FILE="$CONFIG_DIR/config.yaml"
SECRETS_FILE="/run/secrets/secrets.json"
AGGREGATOR="$AGGREGATOR"

# Ensure required files exist
if [ ! -f "$CONFIG_FILE" ]; then
echo "Error: Config file $CONFIG_FILE not found!"
exit 1
Expand All @@ -17,7 +15,6 @@ if [ ! -f "$SECRETS_FILE" ]; then
exit 1
fi

# Read secrets from the JSON file
PRIVATE_KEY=$(jq -r '.private_key' "$SECRETS_FILE")
PASSWORD=$(jq -r '.password' "$SECRETS_FILE")
NETWORK_PRIVATE_KEY=$(jq -r '.network_private_key' "$SECRETS_FILE")
Expand All @@ -27,23 +24,31 @@ if [ -z "$PRIVATE_KEY" ] || [ -z "$PASSWORD" ] || [ -z "$NETWORK_PRIVATE_KEY" ];
exit 1
fi

# Set password and private key
echo "Setting password"
enclave password set --config "$CONFIG_FILE" --password "$PASSWORD"

# Set network private key
echo "Setting network private key"
enclave net set-key --config "$CONFIG_FILE" --net-keypair "$NETWORK_PRIVATE_KEY"

OTEL_ARG=""
if [ -n "$OTEL_EXPORTER_OTLP_ENDPOINT" ]; then
OTEL_ARG="--otel $OTEL_EXPORTER_OTLP_ENDPOINT"
echo "OTEL telemetry enabled: $OTEL_EXPORTER_OTLP_ENDPOINT"
fi

if [ -n "$OTEL_SERVICE_NAME" ]; then
echo "Service name for telemetry: $OTEL_SERVICE_NAME"
fi

if [ "$AGGREGATOR" = "true" ]; then
echo "Setting private key"
enclave wallet set --config "$CONFIG_FILE" --private-key "$PRIVATE_KEY"

echo "Starting aggregator"
exec enclave start -v --config "$CONFIG_FILE"
exec enclave start -v --config "$CONFIG_FILE" $OTEL_ARG
else
echo "Starting Ciphernode"
exec enclave start -v --config "$CONFIG_FILE"
exec enclave start -v --config "$CONFIG_FILE" $OTEL_ARG
fi


6 changes: 3 additions & 3 deletions crates/cli/src/helpers/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ pub fn setup_tracing(config: &AppConfig, log_level: Level) -> Result<()> {
.with_protocol(Protocol::Grpc)
.build()?;

let resource = Resource::builder().with_service_name(name).build();
let service_name =
std::env::var("OTEL_SERVICE_NAME").unwrap_or_else(|_| name.to_string());
let resource = Resource::builder().with_service_name(service_name).build();

let provider = SdkTracerProvider::builder()
.with_batch_exporter(otlp_exporter)
Expand All @@ -48,8 +50,6 @@ pub fn setup_tracing(config: &AppConfig, log_level: Level) -> Result<()> {
.init();
}
None => {
// TODO: we might be able to dedupe this with above but there were
// issues with telemetry so have left this like so for now
tracing_subscriber::registry()
.with(tracing_subscriber::fmt::layer())
.with(tracing_subscriber::filter::LevelFilter::from_level(
Expand Down
53 changes: 42 additions & 11 deletions deploy/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env bash

TIMESTAMP=$(date +%s)
RUN_FILE="./deploy/tmp.docker-compose.${TIMESTAMP}.yml"
TEMPLATE_FILE="./deploy/docker-compose.yml"
RUN_FILE="./tmp.docker-compose.${TIMESTAMP}.yml"
TEMPLATE_FILE="./docker-compose.yml"

wait_ready() {
local STACK_NAME="$1"
Expand All @@ -24,30 +24,61 @@ wait_removed() {
echo "Stack $STACK_NAME is removed"
}

OTEL_ENDPOINT=""
while [[ $# -gt 0 ]]; do
case $1 in
--otel-endpoint)
OTEL_ENDPOINT="$2"
shift 2
;;
*)
if [ -z "$STACK_NAME" ]; then
STACK_NAME="$1"
elif [ -z "$IMAGE_NAME" ]; then
IMAGE_NAME="$1"
else
echo "Error: Unknown argument: $1"
echo "Usage: $0 <stack-name> <image-name> [--otel-endpoint <endpoint>]"
exit 1
fi
shift
;;
esac
done

if [ -z "$1" ]; then
if [ -z "$STACK_NAME" ]; then
echo "Error: Please provide a stack name as an argument"
echo "Usage: $0 <stack-name> <image-name>"
echo "Usage: $0 <stack-name> <image-name> [--otel-endpoint <endpoint>]"
exit 1
fi

if [ -z "$2" ]; then
if [ -z "$IMAGE_NAME" ]; then
echo "Error: Please provide an image name as an argument"
echo "Usage: $0 <stack-name> <image-name>"
echo "Usage: $0 <stack-name> <image-name> [--otel-endpoint <endpoint>]"
exit 1
fi

# Check if docker-compose.yml exists
if [ ! -f "$TEMPLATE_FILE" ]; then
echo "Error: $TEMPLATE_FILE not found"
exit 1
fi

sed "s|{{IMAGE}}|$2|g" $TEMPLATE_FILE > "${RUN_FILE}"
sed "s|{{IMAGE}}|$IMAGE_NAME|g" $TEMPLATE_FILE > "${RUN_FILE}"

COMPOSE_FILES="-c $RUN_FILE"
if [ -n "$OTEL_ENDPOINT" ] && [[ "$OTEL_ENDPOINT" == *"otel-collector"* ]]; then
echo "OTEL enabled with internal collector"
COMPOSE_FILES="$COMPOSE_FILES -c docker-compose.otel.yml"
elif [ -n "$OTEL_ENDPOINT" ]; then
echo "OTEL enabled with external endpoint: $OTEL_ENDPOINT"
else
echo "OTEL disabled"
fi

STACK_NAME=$1
docker stack rm $STACK_NAME
wait_removed $STACK_NAME
docker stack deploy -c $RUN_FILE $STACK_NAME
docker stack deploy $COMPOSE_FILES $STACK_NAME
wait_ready $STACK_NAME
rm ./deploy/tmp.*.*
rm ./tmp.*.*

echo "✅ Stack '$STACK_NAME' deployed successfully!"
1 change: 1 addition & 0 deletions deploy/docker-compose.otel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

16 changes: 10 additions & 6 deletions deploy/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
cn1:
image: {{IMAGE}}
image: { { IMAGE } }
volumes:
- ./cn1.yaml:/home/ciphernode/.config/enclave/config.yaml:ro
- cn1-data:/home/ciphernode/.local/share/enclave
Expand All @@ -12,14 +12,15 @@ services:
AGGREGATOR: "false"
ADDRESS: "0xbDA5747bFD65F08deb54cb465eB87D40e51B197E"
QUIC_PORT: 9091
OTEL_SERVICE_NAME: "enclave-cn1"
deploy:
replicas: 1
endpoint_mode: dnsrr
networks:
- global-network

cn2:
image: {{IMAGE}}
image: { { IMAGE } }
volumes:
- ./cn2.yaml:/home/ciphernode/.config/enclave/config.yaml:ro
- cn2-data:/home/ciphernode/.local/share/enclave
Expand All @@ -29,16 +30,17 @@ services:
env_file: .env
environment:
AGGREGATOR: "false"
ADDRESS: "0xdD2FD4581271e230360230F9337D5c0430Bf44C0"
ADDRESS: "0xdD2FD4581271e230360230F9337D5c0430Bf44C0"
QUIC_PORT: 9092
OTEL_SERVICE_NAME: "enclave-cn2"
deploy:
replicas: 1
endpoint_mode: dnsrr
networks:
- global-network

cn3:
image: {{IMAGE}}
image: { { IMAGE } }
volumes:
- ./cn3.yaml:/home/ciphernode/.config/enclave/config.yaml:ro
- cn3-data:/home/ciphernode/.local/share/enclave
Expand All @@ -50,14 +52,15 @@ services:
AGGREGATOR: "false"
ADDRESS: "0x2546BcD3c84621e976D8185a91A922aE77ECEc30"
QUIC_PORT: 9093
OTEL_SERVICE_NAME: "enclave-cn3"
deploy:
replicas: 1
endpoint_mode: dnsrr
networks:
- global-network

aggregator:
image: {{IMAGE}}
image: { { IMAGE } }
depends_on:
- cn1
volumes:
Expand All @@ -71,6 +74,7 @@ services:
AGGREGATOR: "true"
ADDRESS: "0x8626a6940E2eb28930eFb4CeF49B2d1F2C9C1199"
QUIC_PORT: 9094
OTEL_SERVICE_NAME: "enclave-aggregator"
deploy:
replicas: 1
endpoint_mode: dnsrr
Expand All @@ -85,7 +89,7 @@ secrets:
secrets_cn3:
file: cn3.secrets.json
secrets_agg:
file: agg.secrets.json
file: agg.secrets.json

volumes:
cn1-data:
Expand Down
45 changes: 45 additions & 0 deletions deploy/otel-collector-config-cloud-only.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318

processors:
batch:
timeout: 1s
send_batch_size: 1024

exporters:
debug:
verbosity: detailed
sampling_initial: 5
sampling_thereafter: 200

otlp/signoz-cloud:
endpoint: "${SIGNOZ_ENDPOINT}"
tls:
insecure: false
headers:
"signoz-ingestion-key": "${SIGNOZ_INGESTION_KEY}"

extensions:
health_check:
endpoint: 0.0.0.0:13133
pprof:
endpoint: 0.0.0.0:1777
zpages:
endpoint: 0.0.0.0:55679

service:
extensions: [health_check, pprof, zpages]
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [debug, otlp/signoz-cloud]
logs:
receivers: [otlp]
processors: [batch]
exporters: [debug, otlp/signoz-cloud]
Loading