Skip to content

Commit

Permalink
Merge pull request #137 from hummingbot/staging
Browse files Browse the repository at this point in the history
sync gateway / gateway staging -> main for Hummingbot gateway version 1.17.0
  • Loading branch information
cardosofede authored Jun 26, 2023
2 parents 80f7ea8 + 2dd3a99 commit ac8a088
Show file tree
Hide file tree
Showing 46 changed files with 37,877 additions and 43,591 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
- name: Replace testnet nodeURL for local hardhat node
run: |
mkdir conf db
cp src/templates/* conf
cp -r src/templates/* conf
sed -i 's/https:\/\/rpc.ankr.com\/eth_goerli/http:\/\/127.0.0.1:8545\//g' ./conf/ethereum.yml
sed -i 's/https:\/\/arbitrum-rinkeby.infura.io\/v3/http:\/\/127.0.0.1:8545\//g' ./conf/ethereum.yml
sed -i 's/https:\/\/rpc.ankr.com\/optimism/http:\/\/127.0.0.1:8545\//g' ./conf/ethereum.yml
Expand Down
49 changes: 19 additions & 30 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
# Set the base image
FROM node:18.10.0

# Set labels
LABEL application="gateway-v2"
# WORKDIR /usr/src/app/
WORKDIR /home/gateway

# Copy files
COPY . .

# Dockerfile author / maintainer
LABEL maintainer="Michael Feng <mike@hummingbot.org>"

# Build arguments
LABEL branch=${BRANCH}
LABEL commit=${COMMIT}
LABEL date=${BUILD_DATE}
Expand All @@ -10,37 +19,17 @@ LABEL date=${BUILD_DATE}
ENV COMMIT_BRANCH=${BRANCH}
ENV COMMIT_SHA=${COMMIT}
ENV BUILD_DATE=${DATE}
ENV INSTALLATION_TYPE=docker

# Add hummingbot user and group
RUN groupadd -g 8211 hummingbot && \
useradd -m -s /bin/bash -u 8211 -g 8211 hummingbot
# Create mount points
RUN mkdir -p /home/gateway/conf /home/gateway/logs /home/gateway/db /home/gateway/certs

# Install gosu
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y gosu && \
rm -rf /var/lib/apt/lists/*

# app directory
WORKDIR /usr/src/app/

# copy pwd file to container
COPY . .

RUN ln -s /conf /usr/src/app/conf && \
ln -s /logs /usr/src/app/logs && \
ln -s /certs /usr/src/app/certs

# create app writable directory for db files
RUN mkdir -p /var/lib/gateway /certs /conf /logs /usr/src/app/gateway.level /usr/src/app/transactions.level \
/usr/src/app/db
RUN chown -R hummingbot:hummingbot /var/lib/gateway /usr/src/app/logs /usr/src/app/conf /usr/src/app/certs \
/usr/src/app/gateway.level /usr/src/app/transactions.level /usr/src/app/db /usr/src/app/conf/

# install dependencies
# Install dependencies and compile
RUN yarn install --frozen-lockfile
RUN yarn build

# Expose port 15888 - note that docs port is 8080
EXPOSE 15888

RUN yarn build

CMD ["gosu", "hummingbot:hummingbot", "yarn", "run", "start"]
# Set the default command to run when starting the container
CMD yarn run start
37 changes: 13 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ Hummingbot Gateway is a REST API that exposes connections to various blockchains

Gateway may be used alongside the main [Hummingbot client](https://github.com/hummingbot/hummingbot) to enable trading on DEXs, or as a standalone module by external developers.

## Installation
## Installation via Docker

### Generate certificates
If you are installing Gateway alongside Hummingbot, check out the [Deploy Examples](https://github.com/hummingbot/deploy-examples) repository that helps you deploy various types of Hummingbot and Gateway configurations. For most new users, we recommend following the [Hummingbot Gateway Compose](https://github.com/hummingbot/deploy-examples/tree/main/hummingbot_gateway_compose) deployment.

To run Gateway in `https` (default):
* **CERTS_PATH**: path to folder where Hummingbot generated and saved self-signed SSL certificates
* **PASSPHRASE**: passphrase used to generate the certificates above
The repo also contains [Bash Scripts](https://github.com/hummingbot/deploy-examples/tree/main/bash_scripts#gateway) that help you install the Gateway Docker image on a standalone basis.

### Run Gateway from source
## Installation from source

Dependencies:
* NodeJS (16.0.0 or higher)
Expand All @@ -35,18 +33,7 @@ $ ./gateway-setup.sh
$ yarn start --passphrase=<PASSPHRASE>
```

### Run Gateway using Docker

Dependencies:
* [Docker](https://docker.com)

See the [`/docker`](./docker) folder for Docker installation scripts and instructions on how to use them.


### Build Gateway Docker Image locally

Dependencies:
* [Docker](https://docker.com)
### Build Docker image

To build the gateway docker image locally execute the below make command:

Expand Down Expand Up @@ -84,29 +71,31 @@ There are a number of ways to contribute to gateway.

### Configuration

- Edit `certs_path` in [conf/server.yml](./conf/server.yml) and enter the absolute path to the folder where Hummingbot stored the certificates it created with `gateway generate-certs`. You can also edit this config inside the Hummingbot client by running the command: `gateway config server.certs_path`.

- If you want to turn off `https`, set `unsafeDevModeWithHTTP` to `true` in [conf/server.yml](./conf/server.yml).

- If you want Gateway to log to standard out, set `logToStdOut` to `true` in [conf/server.yml](./conf/server.yml).

- The format of configuration files are dictated by [src/services/config-manager-v2.ts](./src/services/config-manager-v2.ts) and the corresponding schema files in [src/services/schema](./src/services/schema).

- If you want to turn off `https`, set `unsafeDevModeWithHTTP` to `true` in [conf/server.yml](./conf/server.yml).

- For each supported chain, token lists that translate address to symbols for each chain are stored in `/conf/lists`. You can add tokens here to make them available to Gateway.


### Architecture

Here are some files we recommend you look at in order to get familiar with the Gateway codebase:

- [src/services/ethereum-base.ts](./src/services/ethereum-base.ts): base class for EVM chains.
- [src/services/ethereum-base.ts](./src/chains/ethereum/ethereum-base.ts): base class for EVM chains.

- [src/connectors/uniswap/uniswap.ts](./src/connectors/uniswap/uniswap.ts): functionality for interacting with Uniswap.

- [src/services/validator.ts](./src/services/validator.ts): defines functions for validating request payloads.
- [src/services/validators.ts](./src/services/validators.ts): defines functions for validating request payloads.


### Testing

For a pull request merged into the codebase, it has to pass unit test coverage requirements. Take a look at [Workflow](../.github/workflows/workflow.yml) for more details.
For a pull request merged into the codebase, it has to pass unit test coverage requirements. Take a look at [Workflow](./.github/workflows/workflow.yml) for more details.

#### Unit tests

Expand All @@ -126,7 +115,7 @@ yarn jest test/<folder>/<file>

#### Manual tests

We have found it is useful to test individual endpoints with `curl` commands. We have a collection of prepared curl calls. POST bodies are stored in JSON files. Take a look at the [curl calls for gateway](./manual-tests/curl.sh). Note that some environment variables are expected.
We have found it is useful to test individual endpoints with `curl` commands. We have a collection of prepared curl calls. POST bodies are stored in JSON files. Take a look at the [curl calls for gateway](./test-helpers/curl/curl.sh). Note that some environment variables are expected.

## Linting

Expand Down
68 changes: 0 additions & 68 deletions docker/README.md

This file was deleted.

89 changes: 0 additions & 89 deletions docker/gateway-copy-certs.sh

This file was deleted.

Loading

0 comments on commit ac8a088

Please sign in to comment.