From 70cfd206c01a9833d3bd70de81da2feb3e104ada Mon Sep 17 00:00:00 2001 From: Shreerang Kale Date: Fri, 1 Aug 2025 10:57:08 +0530 Subject: [PATCH 1/6] Add Dockerfile --- .dockerignore | 27 +++++++++++++++++++++++++++ Dockerfile | 11 +++++++++++ pyproject.toml | 5 ++++- 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..0c45654 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,27 @@ +.git +.gitignore +README.md +docs/ +*.md +__pycache__/ +*.pyc +*.pyo +*.pyd +.Python +env +pip-log.txt +pip-delete-this-directory.txt +.tox +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.log +.idea +.vscode +.env +errors.db +cache/ +test_e2e.py \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7ab5e77 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM python:3.11-slim + +WORKDIR /app + +COPY . . + +RUN pip install --upgrade pip && pip install . + +RUN mkdir -p /app/cache + +CMD ["python", "-m", "main"] diff --git a/pyproject.toml b/pyproject.toml index dcb87f8..f6aa2d4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,6 +14,9 @@ dependencies = [ "diskcache==5.6.0", ] +[tool.setuptools] +py-modules = ["main", "router", "providers", "errors", "cache", "http_proxy", "ws_proxy", "normalizer"] + [project.optional-dependencies] test = [ "pytest>=7.0.0", @@ -22,4 +25,4 @@ test = [ ] [project.scripts] -solana-proxy = "main:main" \ No newline at end of file +solana-proxy = "main:main" -- 2.45.2 From f52093c5b1d651928f665ee91bea3eebaf3130b1 Mon Sep 17 00:00:00 2001 From: Shreerang Kale Date: Fri, 1 Aug 2025 11:27:59 +0530 Subject: [PATCH 2/6] Implement stack for solana proxy --- stack/README.md | 3 + .../compose/docker-compose-solana-proxy.yml | 33 ++++++++ .../cerc-solana-proxy/build.sh | 5 ++ .../stack/solana-proxy/README.md | 78 +++++++++++++++++++ .../stack/solana-proxy/stack.yml | 8 ++ 5 files changed, 127 insertions(+) create mode 100644 stack/README.md create mode 100644 stack/stack-orchestrator/compose/docker-compose-solana-proxy.yml create mode 100644 stack/stack-orchestrator/container-build/cerc-solana-proxy/build.sh create mode 100644 stack/stack-orchestrator/stack/solana-proxy/README.md create mode 100644 stack/stack-orchestrator/stack/solana-proxy/stack.yml diff --git a/stack/README.md b/stack/README.md new file mode 100644 index 0000000..e299ca6 --- /dev/null +++ b/stack/README.md @@ -0,0 +1,3 @@ +# solana-proxy-stack + +[solana-proxy stack documentation](./stack-orchestrator/stack/solana-proxy/README.md) diff --git a/stack/stack-orchestrator/compose/docker-compose-solana-proxy.yml b/stack/stack-orchestrator/compose/docker-compose-solana-proxy.yml new file mode 100644 index 0000000..e9f9dcc --- /dev/null +++ b/stack/stack-orchestrator/compose/docker-compose-solana-proxy.yml @@ -0,0 +1,33 @@ +services: + # Builds and serves the solana proxy + solana-proxy: + restart: unless-stopped + image: cerc/solana-proxy:local + environment: + # Provider endpoints and auth (optional) + ALCHEMY_API_KEY: ${ALCHEMY_API_KEY} + HELIUS_API_KEY: ${HELIUS_API_KEY} + QUICKNODE_ENDPOINT: ${QUICKNODE_ENDPOINT} + QUICKNODE_TOKEN: ${QUICKNODE_TOKEN} + + # Proxy settings + CACHE_SIZE_GB: 100 + DISABLE_CACHE: ${DISABLE_CACHE} + BACKOFF_MINUTES: 30 + + # Logging + LOG_LEVEL: ${LOG_LEVEL:-INFO} + ERROR_DB_PATH: /app/errors.db + command: ["solana-proxy"] + volumes: + - solana-proxy-data:/app + ports: + - "8545" + healthcheck: + test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8545').read()"] + interval: 30s + timeout: 10s + retries: 3 + +volumes: + solana-proxy-data: diff --git a/stack/stack-orchestrator/container-build/cerc-solana-proxy/build.sh b/stack/stack-orchestrator/container-build/cerc-solana-proxy/build.sh new file mode 100644 index 0000000..35595b7 --- /dev/null +++ b/stack/stack-orchestrator/container-build/cerc-solana-proxy/build.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +# Build cerc/solana-proxy +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh +docker build -t cerc/solana-proxy:local ${build_command_args} ${CERC_REPO_BASE_DIR}/solana-proxy diff --git a/stack/stack-orchestrator/stack/solana-proxy/README.md b/stack/stack-orchestrator/stack/solana-proxy/README.md new file mode 100644 index 0000000..63edbbd --- /dev/null +++ b/stack/stack-orchestrator/stack/solana-proxy/README.md @@ -0,0 +1,78 @@ +# solana-proxy + +Instructions for running the `solana-proxy` using [laconic-so](https://git.vdb.to/cerc-io/stack-orchestrator) + +## Setup + +* Clone the stack repo: + + ```bash + laconic-so fetch-stack git.vdb.to/LaconicNetwork/solana-proxy + ``` + +* Build the container image: + + ```bash + laconic-so --stack ~/cerc/solana-proxy/stack/stack-orchestrator/stack/solana-proxy build-containers + ``` + + This should create the `cerc/solana-proxy` image locally + +## Create a deployment + +* Create a spec file for the deployment: + + ```bash + laconic-so --stack ~/cerc/solana-proxy/stack/stack-orchestrator/stack/solana-proxy deploy init --output solana-proxy-spec.yml + ``` + +* Edit `network` in the spec file to map container ports to host ports as required: + + ```bash + network: + ports: + solana-proxy: + - '8545:8545' + ``` + +* Create a deployment from the spec file: + + ```bash + laconic-so --stack ~/cerc/solana-proxy/stack/stack-orchestrator/stack/solana-proxy deploy create --spec-file solana-proxy-spec.yml --deployment-dir solana-proxy-deployment + ``` + +## Configuration + +* Inside the `solana-proxy-deployment` deployment directory, open `config.env` file and set following env variables: + + ```bash + # Provider endpoints and auth (optional) + ALCHEMY_API_KEY=your_alchemy_key_here + HELIUS_API_KEY=your_helius_key_here + QUICKNODE_ENDPOINT=your_endpoint.quiknode.pro + QUICKNODE_TOKEN=your_quicknode_token_here + + # Proxy settings + DISABLE_CACHE=true + LOG_LEVEL=INFO + ``` + + The proxy will work without API keys using free endpoints, but adding them provides access to premium providers with better rate limits. + +## Start the deployment + +```bash +laconic-so deployment --dir solana-proxy-deployment start +``` + +The Solana RPC proxy will be available at: +- RPC endpoint: +- WebSocket endpoint: + +## Clean up + +* Stop the deployment: + + ```bash + laconic-so deployment --dir solana-proxy-deployment stop + ``` diff --git a/stack/stack-orchestrator/stack/solana-proxy/stack.yml b/stack/stack-orchestrator/stack/solana-proxy/stack.yml new file mode 100644 index 0000000..02f82df --- /dev/null +++ b/stack/stack-orchestrator/stack/solana-proxy/stack.yml @@ -0,0 +1,8 @@ +version: "1.0" +name: solana-proxy +description: "Solana proxy service" +containers: + - cerc/solana-proxy +pods: + - solana-proxy + -- 2.45.2 From 1e84fbbebbb3906f5f3fa5305eebc589bef18597 Mon Sep 17 00:00:00 2001 From: Shreerang Kale Date: Fri, 1 Aug 2025 12:00:24 +0530 Subject: [PATCH 3/6] Make build file executable --- .../stack-orchestrator/container-build/cerc-solana-proxy/build.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 stack/stack-orchestrator/container-build/cerc-solana-proxy/build.sh diff --git a/stack/stack-orchestrator/container-build/cerc-solana-proxy/build.sh b/stack/stack-orchestrator/container-build/cerc-solana-proxy/build.sh old mode 100644 new mode 100755 -- 2.45.2 From 6024059bcb64ed8c4c055e00bee40958b35d4ce8 Mon Sep 17 00:00:00 2001 From: Shreerang Kale Date: Fri, 1 Aug 2025 12:17:12 +0530 Subject: [PATCH 4/6] Update readme --- stack/stack-orchestrator/stack/solana-proxy/README.md | 6 ++++-- stack/stack-orchestrator/stack/solana-proxy/stack.yml | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/stack/stack-orchestrator/stack/solana-proxy/README.md b/stack/stack-orchestrator/stack/solana-proxy/README.md index 63edbbd..0b4b959 100644 --- a/stack/stack-orchestrator/stack/solana-proxy/README.md +++ b/stack/stack-orchestrator/stack/solana-proxy/README.md @@ -66,8 +66,10 @@ laconic-so deployment --dir solana-proxy-deployment start ``` The Solana RPC proxy will be available at: -- RPC endpoint: -- WebSocket endpoint: + +* RPC endpoint: + +* WebSocket endpoint: ## Clean up diff --git a/stack/stack-orchestrator/stack/solana-proxy/stack.yml b/stack/stack-orchestrator/stack/solana-proxy/stack.yml index 02f82df..51f4ce6 100644 --- a/stack/stack-orchestrator/stack/solana-proxy/stack.yml +++ b/stack/stack-orchestrator/stack/solana-proxy/stack.yml @@ -5,4 +5,3 @@ containers: - cerc/solana-proxy pods: - solana-proxy - -- 2.45.2 From f074a9e3b8cc6712105563ce787d2779480abbab Mon Sep 17 00:00:00 2001 From: Shreerang Kale Date: Fri, 1 Aug 2025 16:18:38 +0530 Subject: [PATCH 5/6] Update compose file env vars --- .../compose/docker-compose-solana-proxy.yml | 3 +-- stack/stack-orchestrator/stack/solana-proxy/README.md | 5 +---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/stack/stack-orchestrator/compose/docker-compose-solana-proxy.yml b/stack/stack-orchestrator/compose/docker-compose-solana-proxy.yml index e9f9dcc..78c2dbf 100644 --- a/stack/stack-orchestrator/compose/docker-compose-solana-proxy.yml +++ b/stack/stack-orchestrator/compose/docker-compose-solana-proxy.yml @@ -11,8 +11,7 @@ services: QUICKNODE_TOKEN: ${QUICKNODE_TOKEN} # Proxy settings - CACHE_SIZE_GB: 100 - DISABLE_CACHE: ${DISABLE_CACHE} + CACHE_SIZE_GB: 1 BACKOFF_MINUTES: 30 # Logging diff --git a/stack/stack-orchestrator/stack/solana-proxy/README.md b/stack/stack-orchestrator/stack/solana-proxy/README.md index 0b4b959..d64f3a3 100644 --- a/stack/stack-orchestrator/stack/solana-proxy/README.md +++ b/stack/stack-orchestrator/stack/solana-proxy/README.md @@ -46,14 +46,11 @@ Instructions for running the `solana-proxy` using [laconic-so](https://git.vdb.t * Inside the `solana-proxy-deployment` deployment directory, open `config.env` file and set following env variables: ```bash - # Provider endpoints and auth (optional) + # Optional ALCHEMY_API_KEY=your_alchemy_key_here HELIUS_API_KEY=your_helius_key_here QUICKNODE_ENDPOINT=your_endpoint.quiknode.pro QUICKNODE_TOKEN=your_quicknode_token_here - - # Proxy settings - DISABLE_CACHE=true LOG_LEVEL=INFO ``` -- 2.45.2 From 2c0cce29f86968bb095671214e33886c74b06128 Mon Sep 17 00:00:00 2001 From: Shreerang Kale Date: Fri, 1 Aug 2025 16:22:24 +0530 Subject: [PATCH 6/6] Add cache_policy module to pyproject config --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f6aa2d4..1846520 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,7 @@ dependencies = [ ] [tool.setuptools] -py-modules = ["main", "router", "providers", "errors", "cache", "http_proxy", "ws_proxy", "normalizer"] +py-modules = ["main", "router", "providers", "errors", "cache", "http_proxy", "ws_proxy", "normalizer", "cache_policy"] [project.optional-dependencies] test = [ -- 2.45.2