From 2b6a7614005d26f5637d315e14b82a7ff9d55364 Mon Sep 17 00:00:00 2001 From: segfaultdoctor Date: Wed, 17 Aug 2022 19:03:10 -0700 Subject: [PATCH] chore: update b script (#27) --- b | 45 ++++++++++++++++++++++++++++++++++++--- docker-compose.yaml | 2 ++ env/.env.dev | 4 ++-- env/.env.testnet | 11 ++++++++++ packet_blaster/Cargo.toml | 2 +- 5 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 env/.env.testnet diff --git a/b b/b index 620ee44e1c374b..151d4a81cf87f0 100755 --- a/b +++ b/b @@ -1,18 +1,57 @@ #!/usr/bin/env sh -# Build the relayer container set -e +# dev or testnet +ENV=$1 +ENV_FILE=./env/.env.${ENV} + TAG=$(git describe --match=NeVeRmAtCh --always --abbrev=8 --dirty) ORG="jitolabs" +if [ -f "$ENV_FILE" ]; then + export $(cat "$ENV_FILE" | grep -v '#' | awk '/=/ {print $1}') +else + echo "Missing .env file" + exit 0 +fi + +# A little hacky, but .env files can't execute so this is the best we have for now +if [ "$ENV" = "dev" ]; then + if [ "$(uname)" = "Darwin" ]; then + RPC_SERVERS=http://docker.for.mac.localhost:8899 + WEBSOCKET_SERVERS=ws://docker.for.mac.localhost:8900 + BLOCK_ENGINE_AUTH_SERVICE_URL=http://docker.for.mac.localhost:${BLOCK_ENGINE_AUTH_SERVICE_PORT} + BLOCK_ENGINE_URL=http://docker.for.mac.localhost:${BLOCK_ENGINE_PORT} + elif [ "$(expr substr $(uname -s) 1 5)" = "Linux" ]; then + RPC_SERVERS=http://172.17.0.1:8899 + WEBSOCKET_SERVERS=ws://172.17.0.1:8900 + BLOCK_ENGINE_AUTH_SERVICE_URL=http://172.17.0.1:${BLOCK_ENGINE_AUTH_SERVICE_PORT} + BLOCK_ENGINE_URL=http://172.17.0.1:${BLOCK_ENGINE_PORT} + else + echo "unsupported testing platform, exiting" + exit 1 + fi +elif [ "$ENV" != "mainnet" ] && [ "$ENV" != "testnet" ]; then + echo "ERROR: must run ./b [dev | testnet | mainnet]" + exit 2 +fi + COMPOSE_DOCKER_CLI_BUILD=1 \ DOCKER_BUILDKIT=1 \ + RPC_SERVERS="${RPC_SERVERS}" \ + WEBSOCKET_SERVERS="${WEBSOCKET_SERVERS}" \ + BLOCK_ENGINE_URL="${BLOCK_ENGINE_URL}" \ + BLOCK_ENGINE_AUTH_SERVICE_URL="${BLOCK_ENGINE_AUTH_SERVICE_URL}" \ TAG="${TAG}" \ ORG="${ORG}" \ - docker compose --env-file ./env/.env.dev build --progress=plain + docker compose --env-file "${ENV_FILE}" build --progress=plain COMPOSE_DOCKER_CLI_BUILD=1 \ DOCKER_BUILDKIT=1 \ + RPC_SERVERS="${RPC_SERVERS}" \ + WEBSOCKET_SERVERS="${WEBSOCKET_SERVERS}" \ + BLOCK_ENGINE_URL="${BLOCK_ENGINE_URL}" \ + BLOCK_ENGINE_AUTH_SERVICE_URL="${BLOCK_ENGINE_AUTH_SERVICE_URL}" \ TAG="${TAG}" \ ORG="${ORG}" \ - docker compose --env-file ./env/.env.dev up --remove-orphans + docker compose --env-file "${ENV_FILE}" up --remove-orphans diff --git a/docker-compose.yaml b/docker-compose.yaml index 95e926c729d16e..aa2c5ffdb7a855 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -23,6 +23,8 @@ services: - WEBSOCKET_SERVERS=$WEBSOCKET_SERVERS - SIGNING_KEY_PEM_PATH=$SIGNING_KEY_PEM_PATH - VERIFYING_KEY_PEM_PATH=$VERIFYING_KEY_PEM_PATH + - BLOCK_ENGINE_AUTH_SERVICE_URL=$BLOCK_ENGINE_AUTH_SERVICE_URL + - BLOCK_ENGINE_URL=$BLOCK_ENGINE_URL restart: on-failure volumes: - ./config/keys:/etc/keys diff --git a/env/.env.dev b/env/.env.dev index f59030221b416e..8ed330fd7c6aec 100644 --- a/env/.env.dev +++ b/env/.env.dev @@ -3,7 +3,7 @@ TPU_FWD_PORT=8006 TPU_QUIC_PORT=8011 TPU_QUIC_FWD_PORT=8012 GRPC_BIND_PORT=42069 -RPC_SERVERS="https://api.mainnet-beta.solana.com" -WEBSOCKET_SERVERS="wss://api.mainnet-beta.solana.com" SIGNING_KEY_PEM_PATH=/etc/keys/signing_key.pem VERIFYING_KEY_PEM_PATH=/etc/keys/verifying_key.pem +BLOCK_ENGINE_PORT=13335 +BLOCK_ENGINE_AUTH_SERVICE_PORT=14444 diff --git a/env/.env.testnet b/env/.env.testnet new file mode 100644 index 00000000000000..d8263475e17c55 --- /dev/null +++ b/env/.env.testnet @@ -0,0 +1,11 @@ +TPU_PORT=8005 +TPU_FWD_PORT=8006 +TPU_QUIC_PORT=8011 +TPU_QUIC_FWD_PORT=8012 +GRPC_BIND_PORT=42069 +SIGNING_KEY_PEM_PATH=/etc/keys/signing_key.pem +VERIFYING_KEY_PEM_PATH=/etc/keys/verifying_key.pem +BLOCK_ENGINE_URL=http://145.40.64.176:3000 +BLOCK_ENGINE_AUTH_SERVICE_URL=http://136.144.58.40:14444 +RPC_SERVERS=http://147.28.143.217:8899 +WEBSOCKET_SERVERS=ws://147.28.143.217:8900 \ No newline at end of file diff --git a/packet_blaster/Cargo.toml b/packet_blaster/Cargo.toml index df1fd366bfc8ad..aeb8f8c16dd220 100644 --- a/packet_blaster/Cargo.toml +++ b/packet_blaster/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [dependencies] bincode = "1.3.3" -clap = { version = "3.2.11", features = ["derive"] } +clap = { version = "3.1.12", features = ["derive", "env"] } env_logger = "0.9.0" log = "0.4.17" solana-client = "1.10.24"