diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 32dad29..9085641 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,74 +12,75 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 -# - uses: actions/setup-node@v1 -# with: -# node-version: 12 -# - run: npm ci -# - run: npm run eslint -# - name: Telegram Failure Notification -# uses: appleboy/telegram-action@0.0.7 -# if: failure() -# with: -# message: โ— Build failed for [${{ github.repository }}](https://github.com/${{ github.repository }}/actions) because of ${{ github.actor }} -# format: markdown -# to: ${{ secrets.TELEGRAM_CHAT_ID }} -# token: ${{ secrets.TELEGRAM_BOT_TOKEN }} -# -# publish: -# runs-on: ubuntu-latest -# needs: build -# if: startsWith(github.ref, 'refs/tags') -# steps: -# - name: Checkout -# uses: actions/checkout@v2 -# -# - name: Set vars -# id: vars -# run: | -# echo "::set-output name=version::$(echo ${GITHUB_REF#refs/tags/v})" -# echo "::set-output name=repo_name::$(echo ${GITHUB_REPOSITORY#*/})" -# -# - name: Check package.json version vs tag -# run: | -# [ ${{ steps.vars.outputs.version }} = $(grep '"version":' package.json | grep -o "[0-9.]*") ] || (echo "Git tag doesn't match version in package.json" && false) -# -# - name: Build and push Docker image -# uses: docker/build-push-action@v1.1.0 -# with: -# dockerfile: Dockerfile -# repository: tornadocash/relayer -# tag_with_ref: true -# tags: latest -# username: ${{ secrets.DOCKER_USERNAME }} -# password: ${{ secrets.DOCKER_TOKEN }} -# -# - name: Telegram Message Notify -# uses: appleboy/telegram-action@0.0.7 -# with: -# to: ${{ secrets.TELEGRAM_CHAT_ID }} -# token: ${{ secrets.TELEGRAM_BOT_TOKEN }} -# message: ๐Ÿš€ Published a [${{ steps.vars.outputs.repo_name }}](https://github.com/${{ github.repository }}) version ${{ steps.vars.outputs.version }} to docker hub -# debug: true -# format: markdown -# -# - name: Telegram Notification -# uses: appleboy/telegram-action@0.0.7 -# with: -# to: ${{ secrets.TELEGRAM_RELAYER_CHAT_ID }} -# token: ${{ secrets.TELEGRAM_BOT_TOKEN }} -# message: | -# ๐Ÿš€ Published a new version of the relayer node service to docker hub: `tornadocash/relayer:v${{ steps.vars.outputs.version }}` and `tornadocash/relayer:latest`. -# -# โ—๏ธPlease update your nodes โ—๏ธ -# debug: true -# format: markdown -# -# - name: Telegram Failure Notification -# uses: appleboy/telegram-action@0.0.7 -# if: failure() -# with: -# message: โ— Failed to publish [${{ steps.vars.outputs.repo_name }}](https://github.com/${{ github.repository }}/actions) because of ${{ env.GITHUB_ACTOR }} -# format: markdown -# to: ${{ secrets.TELEGRAM_CHAT_ID }} -# token: ${{ secrets.TELEGRAM_BOT_TOKEN }} + - uses: actions/setup-node@v1 + with: + node-version: 12 + - run: yarn install + - run: yarn test + - run: yarn lint + - name: Telegram Failure Notification + uses: appleboy/telegram-action@0.0.7 + if: failure() + with: + message: โ— Build failed for [${{ github.repository }}](https://github.com/${{ github.repository }}/actions) because of ${{ github.actor }} + format: markdown + to: ${{ secrets.TELEGRAM_CHAT_ID }} + token: ${{ secrets.TELEGRAM_BOT_TOKEN }} + + publish: + runs-on: ubuntu-latest + needs: build + if: startsWith(github.ref, 'refs/tags') + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set vars + id: vars + run: | + echo "::set-output name=version::$(echo ${GITHUB_REF#refs/tags/v})" + echo "::set-output name=repo_name::$(echo ${GITHUB_REPOSITORY#*/})" + + - name: Check package.json version vs tag + run: | + [ ${{ steps.vars.outputs.version }} = $(grep '"version":' package.json | grep -o "[0-9.]*") ] || (echo "Git tag doesn't match version in package.json" && false) + + - name: Build and push Docker image + uses: docker/build-push-action@v1.1.0 + with: + dockerfile: Dockerfile + repository: tornadocash/relayer + tag_with_ref: true + tags: latest + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + + - name: Telegram Message Notify + uses: appleboy/telegram-action@0.0.7 + with: + to: ${{ secrets.TELEGRAM_CHAT_ID }} + token: ${{ secrets.TELEGRAM_BOT_TOKEN }} + message: ๐Ÿš€ Published a [${{ steps.vars.outputs.repo_name }}](https://github.com/${{ github.repository }}) version ${{ steps.vars.outputs.version }} to docker hub + debug: true + format: markdown + + - name: Telegram Notification + uses: appleboy/telegram-action@0.0.7 + with: + to: ${{ secrets.TELEGRAM_RELAYER_CHAT_ID }} + token: ${{ secrets.TELEGRAM_BOT_TOKEN }} + message: | + ๐Ÿš€ Published a new version of the relayer node service to docker hub: `tornadocash/relayer:v${{ steps.vars.outputs.version }}` and `tornadocash/relayer:latest`. + + โ—๏ธPlease update your nodes โ—๏ธ + debug: true + format: markdown + + - name: Telegram Failure Notification + uses: appleboy/telegram-action@0.0.7 + if: failure() + with: + message: โ— Failed to publish [${{ steps.vars.outputs.repo_name }}](https://github.com/${{ github.repository }}/actions) because of ${{ env.GITHUB_ACTOR }} + format: markdown + to: ${{ secrets.TELEGRAM_CHAT_ID }} + token: ${{ secrets.TELEGRAM_BOT_TOKEN }} diff --git a/Dockerfile b/Dockerfile index 48d4ce6..86f4498 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,8 @@ -# syntax=docker/dockerfile:experimental -# export DOCKER_BUILDKIT=1 - FROM node:12 WORKDIR /app -RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts && echo "Host github.com\n\tUser git" > ~/.ssh/config - COPY package.json yarn.lock ./ -RUN --mount=type=ssh yarn && yarn cache clean --force +RUN yarn && yarn cache clean --force COPY . . EXPOSE 8000 diff --git a/README.md b/README.md index fe50765..d929cf5 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ docker-compose.yml contains a stack that will automatically provision SSL certif 1. Download [docker-compose.yml](/docker-compose.yml) and [env.example](/env.example) 2. `mv .env.example .env` 3. Setup environment variables + - set `NET_ID` (1 for mainnet, 5 for Goerli) - set `HTTP_RPC_URL` rpc url for your ethereum node - set `WS_RPC_URL` websocket url @@ -22,6 +23,7 @@ docker-compose.yml contains a stack that will automatically provision SSL certif - update `MAX_GAS_PRICE` if needed - maximum value of gwei value for relayer's transaction If you want to use more than 1 eth address for relaying transactions, please add as many `workers` as you want. For example, you can comment out `worker2` in docker-compose.yml file, but please use a different `PRIVATE_KEY` for each worker. + 4. Run `docker-compose up -d` ## Run locally diff --git a/package.json b/package.json index 2b212c7..e03c7af 100644 --- a/package.json +++ b/package.json @@ -28,8 +28,8 @@ "gas-price-oracle": "^0.2.2", "ioredis": "^4.14.1", "node-fetch": "^2.6.0", - "torn-token": "git+ssh://git@github.com/tornadocash/torn-token.git#04c4df88d470ca7503ef5d97882c56cba4f3647d", - "tornado-cash-anonymity-mining": "git+ssh://git@github.com/tornadocash/tornado-anonymity-mining.git#b13228c20126f212ebbcc5a8493ce2105210739e", + "torn-token": "^1.0.0", + "tornado-cash-anonymity-mining": "^1.0.0", "tx-manager": "^0.2.9", "uuid": "^8.3.0", "web3": "^1.3.0", diff --git a/yarn.lock b/yarn.lock index b601a8a..aab356c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4322,9 +4322,10 @@ toidentifier@1.0.0: resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553" integrity sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw== -"torn-token@git+ssh://git@github.com/tornadocash/torn-token.git#04c4df88d470ca7503ef5d97882c56cba4f3647d": +torn-token@^1.0.0: version "1.0.0" - resolved "git+ssh://git@github.com/tornadocash/torn-token.git#04c4df88d470ca7503ef5d97882c56cba4f3647d" + resolved "https://registry.yarnpkg.com/torn-token/-/torn-token-1.0.0.tgz#73e47025646c3e07ab733afbf7aa53b6ab9cad55" + integrity sha512-BRzt3fy4211jCb64cWyOb5/NMGt9M9EV2ZFnGQYMubKrVkszoYm97Nex+EBa0mvV2KfXzCmJ6tehoDgOFAPGug== dependencies: "@openzeppelin/contracts" "^3.1.0" dotenv "^8.2.0" @@ -4332,9 +4333,10 @@ toidentifier@1.0.0: ethereumjs-util "^7.0.3" web3 "^1.2.11" -"tornado-cash-anonymity-mining@git+ssh://git@github.com/tornadocash/tornado-anonymity-mining.git#b13228c20126f212ebbcc5a8493ce2105210739e": +tornado-cash-anonymity-mining@^1.0.0: version "1.0.0" - resolved "git+ssh://git@github.com/tornadocash/tornado-anonymity-mining.git#b13228c20126f212ebbcc5a8493ce2105210739e" + resolved "https://registry.yarnpkg.com/tornado-cash-anonymity-mining/-/tornado-cash-anonymity-mining-1.0.0.tgz#1e9d68e60097de6fa3ff6989558ca313030daf5c" + integrity sha512-OVwj1N6g6NqRrkj0QkSrrGSY7Mlmb0BMeJUh7BeI9doOY/tS1OMky/G/xHdcVRLTbJN34MHIepTSF6/xRM33eg== dependencies: circomlib "git+https://github.com/tornadocash/circomlib.git#3b492f9801573eebcfe1b6c584afe8a3beecf2b4" decimal.js "^10.2.0"