-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from skalenetwork/feature/SKALE-4289-refactor-p…
…roxy SKALE-4289 SKALE Proxy v2
- Loading branch information
Showing
38 changed files
with
907 additions
and
664 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[flake8] | ||
max-line-length = 100 | ||
exclude = .git,__pycache__,docs/source/conf.py,old,build,dist,venv,node_modules,helper-scripts |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Build and publish | ||
on: | ||
pull_request: | ||
types: [closed] | ||
branches: | ||
- master | ||
- develop | ||
- beta | ||
- stable | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
if: github.event.pull_request.merged | ||
env: | ||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: true | ||
- name: Set up Python 3.7 | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: 3.7 | ||
- name: Build and publish container | ||
run: | | ||
export BRANCH=${GITHUB_REF##*/} | ||
export VERSION=$(cat VERSION) | ||
echo "Branch: $BRANCH" | ||
echo "Base version: $VERSION" | ||
export VERSION=$(bash ./helper-scripts/calculate_version.sh) | ||
echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
echo "Version $VERSION" | ||
export RELEASE=true | ||
echo "RELEASE=$RELEASE" >> $GITHUB_ENV | ||
export CONTAINER_NAME="proxy" | ||
bash ./helper-scripts/build_and_publish.sh | ||
- name: Checkout code | ||
uses: actions/checkout@master | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ env.VERSION }} | ||
release_name: ${{ env.VERSION }} | ||
draft: false | ||
prerelease: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
*.crt | ||
*.key | ||
.env | ||
|
||
venv | ||
|
||
__pycache__ | ||
|
||
abi.json | ||
chains.json | ||
|
||
conf/upstreams/*.conf | ||
conf/chains/*.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
[submodule "proxy-ui"] | ||
path = proxy-ui | ||
url = https://github.com/skalenetwork/proxy-ui.git | ||
branch = master | ||
branch = beta | ||
[submodule "helper-scripts"] | ||
path = helper-scripts | ||
url = https://github.com/skalenetwork/helper-scripts.git | ||
branch = develop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,16 @@ | ||
FROM ubuntu:20.04 | ||
|
||
# Keep upstart from complaining | ||
RUN dpkg-divert --local --rename --add /sbin/initctl | ||
RUN ln -sf /bin/true /sbin/initctl | ||
|
||
# Let the conatiner know that there is no tty | ||
ENV DEBIAN_FRONTEND noninteractive | ||
FROM python:3.9-buster | ||
|
||
RUN apt-get update | ||
RUN apt-get -y upgrade | ||
|
||
# Basic Requirements | ||
RUN apt-get -y install nginx pwgen python3 python3-pip curl git unzip vim | ||
|
||
RUN pip3 install web3==5.13.1 | ||
|
||
# nginx config | ||
RUN sed -i -e"s/keepalive_timeout\s*65/keepalive_timeout 2/" /etc/nginx/nginx.conf | ||
RUN sed -i -e"s/keepalive_timeout 2/keepalive_timeout 2;\n\tclient_max_body_size 100m/" /etc/nginx/nginx.conf | ||
RUN echo "daemon off;" >> /etc/nginx/nginx.conf | ||
|
||
# nginx site conf | ||
ADD sample/nginx-site.conf /etc/nginx/sites-available/default | ||
COPY abi /etc/ | ||
RUN mkdir /usr/src/proxy /data | ||
WORKDIR /usr/src/proxy | ||
|
||
RUN pip3 install web3==5.13.1 | ||
COPY requirements.txt ./ | ||
RUN pip3 install --no-cache-dir -r requirements.txt | ||
|
||
ADD ./endpoints.py /etc/endpoints.py | ||
ADD ./periodic_config_update.py /etc/periodic_config_update.py | ||
ADD ./VERSION /etc/VERSION | ||
COPY . . | ||
|
||
# Initialization and Startup Script | ||
ADD ./start.sh /start.sh | ||
RUN chmod 755 /start.sh | ||
ENV PYTHONPATH="/usr/src/proxy" | ||
ENV COLUMNS=80 | ||
|
||
CMD ["/bin/bash", "/start.sh"] | ||
CMD python /usr/src/proxy/proxy/main.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,39 @@ | ||
# skale-proxy | ||
# SKALE Proxy | ||
|
||
skale-proxy is a public service that provides proxied and load-balanced JSON-RPC endpoints for SKALE chains | ||
[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB) | ||
|
||
SKALE Proxy is high performance, easy-to-run public service that provides proxied and load-balanced | ||
JSON-RPC endpoints for SKALE chains. It is based on NGINX. | ||
|
||
# running | ||
## Usage guide | ||
|
||
### Prerequisites | ||
|
||
1. Place you ABI json file into abi directory | ||
- Docker | ||
- docker-compose | ||
|
||
2. Set 'ABI_FILENAME directory' in docker-compose.yml to the name of the ABI file. | ||
|
||
3. Set 'PROXY_FULL_HOST_NAME' in docker-compose.yml to the domain name of your proxy. | ||
### Repo setup | ||
|
||
4. Set 'ENDPOINT_PREFIX' in 'docker-compose.yml' to the endpoint prefix (must be non-empty!) | ||
1. Clone repo & all submodules | ||
2. Put `abi.json`, `server.crt` and `server.key`files in `data` folder | ||
3. Export all required environement variables (see below) | ||
4. Run `scripts/run_proxy.sh` | ||
|
||
5. Set 'ETH_ENDPOINT' in docker-compose to your ETH main net endpoint. | ||
#### Required environement variables | ||
|
||
6. Create 'data' directory and copy 'server.crt' and 'server.key' to it. | ||
The certificate need to be issued to 'PROXY_FULL_HOST_NAME'. | ||
- `NETWORKS` | ||
- `DOCS_WEBSITE_URL` | ||
- `MAIN_WEBSITE_URL` | ||
- `NETWORK_NAME` | ||
- `CHAIN_ID` | ||
- `EXPLORER_URL` | ||
- `BASE_PROXY_URL` | ||
- `ETH_ENDPOINT` | ||
|
||
|
||
7. Run 'docker-compose pull && docker-compose up' andf wait around a minute until skale-proxy reads schain info from blockchain and starts. | ||
## License | ||
|
||
8. Try 'http://PROXY_FULL_HOST_NAME/api.json' . You should be able to see API descriptions. | ||
[![License](https://img.shields.io/github/license/skalenetwork/skale-proxy.svg)](LICENSE) | ||
|
||
Voila! | ||
|
||
# local development | ||
|
||
Set `FULL_PROXY_DOMAIN_NAME` to localhost and run `cert_gen.sh`. This will generate a self-signed cert in the `data/` directory. | ||
All contributions to SKALE Proxy are made under the [GNU Affero General Public License v3](https://www.gnu.org/licenses/agpl-3.0.en.html). See [LICENSE](LICENSE). | ||
|
||
Copyright (C) 2022-Present SKALE Labs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.77.1 | ||
2.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
events { | ||
worker_connections 100000; | ||
} | ||
|
||
http { | ||
|
||
limit_req_zone $binary_remote_addr zone=one:10m rate=15r/s; | ||
client_max_body_size 5M; | ||
|
||
server { | ||
listen 80; | ||
listen 443 ssl; | ||
ssl_certificate /data/server.crt; | ||
ssl_certificate_key /data/server.key; | ||
server_name _; | ||
|
||
limit_req zone=one burst=100; | ||
|
||
proxy_read_timeout 500s; | ||
proxy_connect_timeout 500s; | ||
proxy_send_timeout 500s; | ||
|
||
location / { | ||
proxy_http_version 1.1; | ||
proxy_pass http://proxy-ui:5001/; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection 'upgrade'; | ||
proxy_set_header Host $host; | ||
proxy_cache_bypass $http_upgrade; | ||
} | ||
|
||
location /files/ { | ||
root /usr/share/nginx/www; | ||
} | ||
|
||
include /etc/nginx/conf/chains/*.conf; | ||
} | ||
|
||
include /etc/nginx/conf/upstreams/*.conf; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.