Skip to content

Commit

Permalink
Apply rebranding changes (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-hermes authored Dec 9, 2024
1 parent 4cab47f commit be994c9
Show file tree
Hide file tree
Showing 24 changed files with 267 additions and 267 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ venv.bak/
.idea/inspectionProfiles/
.idea/misc.xml
.idea/modules.xml
.idea/ton_client.iml
.idea/ion_client.iml
.idea/vcs.xml

## tonlib chaotically created temp blkstate files
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- name: Prepare
id: prepare
run: |
DOCKER_IMAGE=toncenter/ton-http-api
DOCKER_IMAGE=ice-blockchain/ion-http-api
if ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
then
Expand All @@ -65,7 +65,7 @@ jobs:
echo ::set-output name=docker_image::${DOCKER_IMAGE}
echo ::set-output name=version::${VERSION}
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \
${TAGS} --file ton-http-api/.docker/Dockerfile ton-http-api \
${TAGS} --file ion-http-api/.docker/Dockerfile ion-http-api \
--cache-from=${DOCKER_IMAGE}:latest
echo "Pulling latest image for cache"
Expand All @@ -79,16 +79,16 @@ jobs:
run: |
docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }}
- name: Login to DockerHub
if: success() && github.repository == 'toncenter/ton-http-api' && github.event_name == 'push' && github.ref == 'refs/heads/master'
if: success() && github.repository == 'ice-blockchain/ion-http-api' && github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Docker Buildx (push)
if: success() && github.repository == 'toncenter/ton-http-api' && github.event_name == 'push' && github.ref == 'refs/heads/master'
if: success() && github.repository == 'ice-blockchain/ion-http-api' && github.event_name == 'push' && github.ref == 'refs/heads/master'
run: |
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
- name: Inspect image
if: always() && github.repository == 'toncenter/ton-http-api' && github.event_name == 'push' && github.ref == 'refs/heads/master'
if: always() && github.repository == 'ice-blockchain/ion-http-api' && github.event_name == 'push' && github.ref == 'refs/heads/master'
run: |
docker buildx imagetools inspect ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}
22 changes: 11 additions & 11 deletions .github/workflows/build-wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,41 +39,41 @@ jobs:
python-version: 3.8
- name: Install build dependencies
shell: bash -l {0}
working-directory: ./ton-http-api/
working-directory: ./ion-http-api/
run: |
python -m pip install build wheel
python -m pip install -r requirements.txt
- name: Build distributions
shell: bash -l {0}
working-directory: ./ton-http-api/
run: TON_HTTP_API_VERSION=${{ needs.set_version.outputs.version }} python setup.py sdist bdist_wheel
working-directory: ./ion-http-api/
run: ION_HTTP_API_VERSION=${{ needs.set_version.outputs.version }} python setup.py sdist bdist_wheel
- name: Check distributions
shell: bash -l {0}
working-directory: ./ton-http-api/
working-directory: ./ion-http-api/
run: |
echo $(pwd)
ls $(pwd)/
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ton-http-api-package
name: ion-http-api-package
path: |
ton-http-api/dist/*.whl
ton-http-api/dist/*.tar.gz
ion-http-api/dist/*.whl
ion-http-api/dist/*.tar.gz
upload-pypi:
runs-on: ubuntu-20.04
needs: [ set_version, build_wheel ]
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: ton-http-api-package
name: ion-http-api-package
path: dist
- name: Check distributions
shell: bash -l {0}
run: ls -la dist/
- name: Create release tag
if: ${{ github.repository == 'toncenter/ton-http-api' && github.event_name == 'push' && github.ref == 'refs/heads/master' }}
if: ${{ github.repository == 'ice-blockchain/ion-http-api' && github.event_name == 'push' && github.ref == 'refs/heads/master' }}
uses: actions/github-script@v3
with:
github-token: ${{ github.token }}
Expand All @@ -85,14 +85,14 @@ jobs:
sha: context.sha
})
- name: Publish package to test PyPI
if: ${{ github.repository == 'toncenter/ton-http-api' && github.event_name == 'push' }}
if: ${{ github.repository == 'ice-blockchain/ion-http-api' && github.event_name == 'push' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_PASSWORD }}
repository_url: https://test.pypi.org/legacy/
- name: Publish package to PyPI
if: ${{ github.repository == 'toncenter/ton-http-api' && github.event_name == 'push' && github.ref == 'refs/heads/master' }}
if: ${{ github.repository == 'ice-blockchain/ion-http-api' && github.event_name == 'push' && github.ref == 'refs/heads/master' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ venv.bak/
.idea/inspectionProfiles/
.idea/misc.xml
.idea/modules.xml
.idea/ton_client.iml
.idea/ion_client.iml
.idea/vcs.xml

## tonlib chaotically created temp blkstate files
Expand All @@ -125,4 +125,4 @@ venv.bak/
.DS_Store

/sandbox
/ton_keystore
/ion_keystore
92 changes: 46 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
![splash_http_api](https://user-images.githubusercontent.com/1449561/154847286-989a6c51-1615-45e1-b40f-aec7c13014fa.png)

# HTTP API for [The Open Network](https://ton.org)
# HTTP API for [Ice Open Network](https://ion.org)

[![PyPI](https://img.shields.io/pypi/v/ton-http-api?color=blue)](https://pypi.org/project/ton-http-api/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ton-http-api)](https://pypi.org/project/ton-http-api/)
[![Docker - Image Version](https://img.shields.io/docker/v/toncenter/ton-http-api?label=docker&sort=semver)](https://hub.docker.com/repository/docker/toncenter/ton-http-api)
[![Docker - Image Size](https://img.shields.io/docker/image-size/toncenter/ton-http-api?label=docker&sort=semver)](https://hub.docker.com/repository/docker/toncenter/ton-http-api)
![Github last commit](https://img.shields.io/github/last-commit/toncenter/ton-http-api)
[![PyPI](https://img.shields.io/pypi/v/ion-http-api?color=blue)](https://pypi.org/project/ion-http-api/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ion-http-api)](https://pypi.org/project/ion-http-api/)
[![Docker - Image Version](https://img.shields.io/docker/v/ice-blockchain/ion-http-api?label=docker&sort=semver)](https://hub.docker.com/repository/docker/ice-blockchain/ion-http-api)
[![Docker - Image Size](https://img.shields.io/docker/image-size/ice-blockchain/ion-http-api?label=docker&sort=semver)](https://hub.docker.com/repository/docker/ice-blockchain/ion-http-api)
![Github last commit](https://img.shields.io/github/last-commit/ice-blockchain/ion-http-api)

Since TON nodes uses its own ADNL binary transport protocol, a intermediate service is needed for an HTTP connection.
Since ION nodes uses its own ADNL binary transport protocol, a intermediate service is needed for an HTTP connection.

TON HTTP API is such a intermediate service, receiving requests via HTTP, it accesses the lite servers of the TON network using `tonlibjson`.
ION HTTP API is such a intermediate service, receiving requests via HTTP, it accesses the lite servers of the ION network using `tonlibjson`.

You can use the ready-made [toncenter.com](https://toncenter.com) service or start your own instance.
You can use the ready-made [ice-blockchain.com](https://ice-blockchain.com) service or start your own instance.

## Building and running

Expand All @@ -21,27 +21,27 @@ Recommended hardware:
- HTTP API only: 1 vCPU, 2 GB RAM.
- HTTP API with cache enabled: 2 vCPUs, 4 GB RAM.

There are two main ways to run TON HTTP API:
There are two main ways to run ION HTTP API:
- __Local__ *(experimental)*: works on following platforms: Ubuntu Linux (x86_64, arm64), MacOSX (Intel x86_64, Apple M1 arm64) and Windows (x86_64).
- __Docker Compose__: flexible configuration, recommended for production environments, works on any x86_64 and arm64 OS with Docker available.

### Local run *(experimental)*
**Note:** It is simple but not stable way to run the service. We do not recommend to use it in production.
- (Windows only, first time) Install OpenSSL v1.1.1 for win64 from [here](https://slproweb.com/products/Win32OpenSSL.html).
- Install package: `pip install ton-http-api`.
- Run service with `ton-http-api`. This command will run service with [mainnet](https://ton.org/global-config.json) configuration.
- Run `ton-http-api --help` to show parameters list.
- Install package: `pip install ion-http-api`.
- Run service with `ion-http-api`. This command will run service with [mainnet](https://cdn.ice.io/mainnet/global.config.json) configuration.
- Run `ion-http-api --help` to show parameters list.

### Docker Compose
- (First time) Install required tools: `docker`, `docker-compose`, `curl`.
- For Ubuntu: run `scripts/setup.sh` from the root of the repo.
- For MacOS and Windows: install [Docker Desktop](https://www.docker.com/products/docker-desktop/).
- **Note:** we recommend to use Docker Compose V2.
- Download TON configuration files to private folder:
- Download ION configuration files to private folder:
```bash
mkdir private
curl -sL https://ton-blockchain.github.io/global.config.json > private/mainnet.json
curl -sL https://ton-blockchain.github.io/testnet-global.config.json > private/testnet.json
curl -sL https://cdn.ice.io/mainnet/global.config.json > private/mainnet.json
curl -sL https://cdn.ice.io/testnet/testnet-global.config.json > private/testnet.json
```
- Run `./configure.py` to create `.env` file with necessary environment variables (see [Configuration](#Configuration) for details).
- Build services: `docker-compose build`.
Expand All @@ -53,113 +53,113 @@ There are two main ways to run TON HTTP API:

You should specify environment parameters and run `./configure.py` to create `.env` file.
```bash
export TON_API_LITESERVER_CONFIG=private/testnet.json
export ION_API_LITESERVER_CONFIG=private/testnet.json
./configure.py
```

The service supports the following environment variables:
#### Webserver settings
- `TON_API_HTTP_PORT` *(default: 80)*
- `ION_API_HTTP_PORT` *(default: 80)*

Port for HTTP connections of API service.

- `TON_API_ROOT_PATH` *(default: /)*
- `ION_API_ROOT_PATH` *(default: /)*

If you use a proxy server such as Nginx or Traefik you might change the default API path prefix (e.g. `/api/v2`). If so you have to pass the path prefix to the API service in this variable.

- `TON_API_WEBSERVERS_WORKERS` *(default: 1)*
- `ION_API_WEBSERVERS_WORKERS` *(default: 1)*

Number of webserver processes. If your server is under high load try increase this value to increase RPS. We recommend setting it to number of CPU cores / 2.

- `TON_API_GET_METHODS_ENABLED` *(default: 1)*
- `ION_API_GET_METHODS_ENABLED` *(default: 1)*

Enables `runGetMethod` endpoint.

- `TON_API_JSON_RPC_ENABLED` *(default: 1)*
- `ION_API_JSON_RPC_ENABLED` *(default: 1)*

Enables `jsonRPC` endpoint.

- `TON_API_LOGS_JSONIFY` *(default: 0)*
- `ION_API_LOGS_JSONIFY` *(default: 0)*

Enables printing all logs in json format.

- `TON_API_LOGS_LEVEL` *(default: ERROR)*
- `ION_API_LOGS_LEVEL` *(default: ERROR)*

Defines log verbosity level. Values allowed: `DEBUG`,`INFO`,`WARNING`,`ERROR`,`CRITICAL`.

- `TON_API_GUNICORN_FLAGS` *(default: empty)*
- `ION_API_GUNICORN_FLAGS` *(default: empty)*

Additional Gunicorn [command line arguments](https://docs.gunicorn.org/en/stable/settings.html).

#### Tonlib settings
- `TON_API_TONLIB_LITESERVER_CONFIG` *(default docker: private/mainnet.json local: https://ton.org/global-config.json)*
- `ION_API_TONLIB_LITESERVER_CONFIG` *(default docker: private/mainnet.json local: https://cdn.ice.io/mainnet/global.config.json)*

Path to config file with lite servers information. In case of native run you can pass URL to download config. Docker support only path to file.

- `TON_API_TONLIB_KEYSTORE` *(default docker: /tmp/ton_keystore local: ./ton_keystore/)*
- `ION_API_TONLIB_KEYSTORE` *(default docker: /tmp/ion_keystore local: ./ion_keystore/)*

Path to tonlib keystore.

- `TON_API_TONLIB_PARALLEL_REQUESTS_PER_LITESERVER` *(default: 50)*
- `ION_API_TONLIB_PARALLEL_REQUESTS_PER_LITESERVER` *(default: 50)*

Number of maximum parallel requests count per worker.

- `TON_API_TONLIB_CDLL_PATH` *(default: empty)*
- `ION_API_TONLIB_CDLL_PATH` *(default: empty)*

Path to tonlibjson binary. It could be useful if you want to run service on unsupported platform and have built the `libtonlibjson` library manually.

- `TON_API_TONLIB_REQUEST_TIMEOUT` *(default: 10)*
- `ION_API_TONLIB_REQUEST_TIMEOUT` *(default: 10)*

Timeout for liteserver requests.

#### Cache configuration
- `TON_API_CACHE_ENABLED` *(default: 0)*
- `ION_API_CACHE_ENABLED` *(default: 0)*

Enables caching lite server responses with Redis.

- `TON_API_CACHE_REDIS_ENDPOINT` *(default: localhost, docker: cache_redis)*
- `ION_API_CACHE_REDIS_ENDPOINT` *(default: localhost, docker: cache_redis)*

Redis cache service host.

- `TON_API_CACHE_REDIS_PORT` *(default: 6379)*
- `ION_API_CACHE_REDIS_PORT` *(default: 6379)*

Redis cache service port.

- `TON_API_CACHE_REDIS_TIMEOUT` *(default: 1)*
- `ION_API_CACHE_REDIS_TIMEOUT` *(default: 1)*

Redis cache timeout.


## FAQ
#### How to point the service to my own lite server?

To point the HTTP API to your own lite server you should set `TON_API_TONLIB_LITESERVER_CONFIG` to config file with your only lite server.
To point the HTTP API to your own lite server you should set `ION_API_TONLIB_LITESERVER_CONFIG` to config file with your only lite server.

- If you use MyTonCtrl on your node you can generate config file with these commands:
- If you use MyIonCtrl on your node you can generate config file with these commands:
```
$ mytonctrl
MyTonCtrl> installer
MyTonInstaller> clcf
$ myionctrl
MyIonCtrl> installer
MyIonInstaller> clcf
```
Config file will be saved at `/usr/bin/ton/local.config.json`.
- If you don't use MyTonCtrl: copy `private/mainnet.json` and overwrite section `liteservers` with your liteservers ip, port and public key. To get public key from `liteserver.pub` file use the following script:
Config file will be saved at `/usr/bin/ion/local.config.json`.
- If you don't use MyIonCtrl: copy `private/mainnet.json` and overwrite section `liteservers` with your liteservers ip, port and public key. To get public key from `liteserver.pub` file use the following script:
```
python -c 'import codecs; f=open("liteserver.pub", "rb+"); pub=f.read()[4:]; print(str(codecs.encode(pub,"base64")).replace("\n",""))'
```
- The config generated with `mytonctrl` > `installer` > `clcf` adds the public IP of your server in the config file. If there's an active firewall on your server, `ton-http-api` won't be able to connect to the local lite server. In that case, replace the value of lite server's `ip` in `local.config.json` with `2130706433`, which is the integer equivalent of `127.0.0.1` / `localhost`.
- Once config file is created assign variable `TON_API_TONLIB_LITESERVER_CONFIG` to its path, run `./configure.py` and rebuild the project.
- The config generated with `myionctrl` > `installer` > `clcf` adds the public IP of your server in the config file. If there's an active firewall on your server, `ion-http-api` won't be able to connect to the local lite server. In that case, replace the value of lite server's `ip` in `local.config.json` with `2130706433`, which is the integer equivalent of `127.0.0.1` / `localhost`.
- Once config file is created assign variable `ION_API_TONLIB_LITESERVER_CONFIG` to its path, run `./configure.py` and rebuild the project.

#### How to run multiple API instances on single machine?

- Clone the repo as many times as many instances you need to the folders with different names (otherwise docker compose containers will conflict).
- Configure each instance to use unique port (env variable `TON_API_HTTP_PORT`)
- Configure each instance to use unique port (env variable `ION_API_HTTP_PORT`)
- Build and run every instance.

#### How to update tonlibjson library?

Binary file `libtonlibjson` now moved to [pytonlib](https://github.com/toncenter/pytonlib).
Binary file `libtonlibjson` now moved to [pytonlib](https://github.com/ice-blockchain/pytonlib).
- Docker Compose: `docker-compose build --no-cache`.
- Local run: `pip install -U ton-http-api`.
- Local run: `pip install -U ion-http-api`.

### No working liteservers error.

Expand Down
36 changes: 18 additions & 18 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@


LOCAL_ENV = {
'TON_API_CACHE_ENABLED': '0',
'TON_API_CACHE_REDIS_ENDPOINT': 'cache_redis',
'TON_API_CACHE_REDIS_PORT': '6379',
'TON_API_CACHE_REDIS_TIMEOUT': '1',
'TON_API_LOGS_JSONIFY': '0',
'TON_API_LOGS_LEVEL': 'ERROR',
'TON_API_GET_METHODS_ENABLED': '1',
'TON_API_HTTP_PORT': '80',
'TON_API_JSON_RPC_ENABLED': '1',
'TON_API_ROOT_PATH': '/',
'TON_API_WEBSERVERS_WORKERS': '1',
'TON_API_TONLIB_LITESERVER_CONFIG': 'private/mainnet.json',
'TON_API_TONLIB_KEYSTORE': '/tmp/ton_keystore/',
'TON_API_TONLIB_PARALLEL_REQUESTS_PER_LITESERVER': '50',
'TON_API_TONLIB_CDLL_PATH': '',
'TON_API_TONLIB_REQUEST_TIMEOUT': '10',
'TON_API_GUNICORN_FLAGS': ''
'ION_API_CACHE_ENABLED': '0',
'ION_API_CACHE_REDIS_ENDPOINT': 'cache_redis',
'ION_API_CACHE_REDIS_PORT': '6379',
'ION_API_CACHE_REDIS_TIMEOUT': '1',
'ION_API_LOGS_JSONIFY': '0',
'ION_API_LOGS_LEVEL': 'ERROR',
'ION_API_GET_METHODS_ENABLED': '1',
'ION_API_HTTP_PORT': '80',
'ION_API_JSON_RPC_ENABLED': '1',
'ION_API_ROOT_PATH': '/',
'ION_API_WEBSERVERS_WORKERS': '1',
'ION_API_TONLIB_LITESERVER_CONFIG': 'private/mainnet.json',
'ION_API_TONLIB_KEYSTORE': '/tmp/ion_keystore/',
'ION_API_TONLIB_PARALLEL_REQUESTS_PER_LITESERVER': '50',
'ION_API_TONLIB_CDLL_PATH': '',
'ION_API_TONLIB_REQUEST_TIMEOUT': '10',
'ION_API_GUNICORN_FLAGS': ''
}


Expand All @@ -41,7 +41,7 @@ def main():

compose_file = 'docker-compose.yaml'

cache_enabled = strtobool(default_env['TON_API_CACHE_ENABLED'])
cache_enabled = strtobool(default_env['ION_API_CACHE_ENABLED'])
if cache_enabled:
compose_file += ':docker-compose.cache.yaml'
default_env['COMPOSE_FILE'] = compose_file
Expand Down
Loading

0 comments on commit be994c9

Please sign in to comment.