mirror of
https://github.com/tornadocash/tornado-relayer.git
synced 2024-10-01 08:25:37 -04:00
commit
c45dabebf2
25
README.md
25
README.md
@ -1,22 +1,23 @@
|
|||||||
# Relayer for Tornado mixer [![Build Status](https://travis-ci.org/tornadocash/relayer.svg?branch=master)](https://travis-ci.org/tornadocash/relayer) [![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/tornadocash/relayer.svg)](https://hub.docker.com/r/tornadocash/relayer/builds)
|
# Relayer for Tornado mixer [![Build Status](https://travis-ci.org/tornadocash/relayer.svg?branch=master)](https://travis-ci.org/tornadocash/relayer) [![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/tornadocash/relayer.svg)](https://hub.docker.com/r/tornadocash/relayer/builds)
|
||||||
|
|
||||||
## Setup
|
## Run locally
|
||||||
1. `npm i`
|
1. `npm i`
|
||||||
2. `cp .env.example .env`
|
2. `cp .env.example .env`
|
||||||
3. Modify `.env` as needed
|
3. Modify `.env` as needed
|
||||||
4. If you want to change contracts' addresses go to [config.js](./config.js) file.
|
4. `npm run start`
|
||||||
|
5. Go to `http://127.0.0.1:8000`
|
||||||
## Deploy Kovan
|
6. In order to execute withdraw request, you can run following command
|
||||||
1. `cp .env.example deploy/kovan/.env`
|
```bash
|
||||||
2. `cd deploy/kovan`
|
curl -X POST -H 'content-type:application/json' --data '<input data>' http://127.0.0.1:8000/relay
|
||||||
2. Modify `.env` as needed
|
```
|
||||||
3. `docker-compose -p kovan up -d`
|
|
||||||
|
|
||||||
## Run locally
|
|
||||||
1. `npm run start`
|
|
||||||
2. `curl -X POST -H 'content-type:application/json' --data '<input data>' http://127.0.0.1:8000/relay`
|
|
||||||
Relayer should return a transaction hash.
|
Relayer should return a transaction hash.
|
||||||
|
|
||||||
|
*Note.* If you want to change contracts' addresses go to [config.js](./config.js) file.
|
||||||
|
|
||||||
|
## Deploy as a Docker container
|
||||||
|
1. `cp .env.example .env`
|
||||||
|
2. Modify `.env` as needed
|
||||||
|
3. `docker run -d --env-file .env -p 80:8000 tornadocash/relayer`
|
||||||
|
|
||||||
## Input data example
|
## Input data example
|
||||||
```json
|
```json
|
||||||
|
@ -50,7 +50,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
defaultGasPrice: 2,
|
defaultGasPrice: 2,
|
||||||
gasOracleUrls: ['https://www.etherchain.org/api/gasPriceOracle', 'https://gasprice.poa.network/'],
|
gasOracleUrls: ['https://ethgasstation.info/json/ethgasAPI.json', 'https://gasprice.poa.network/'],
|
||||||
port: process.env.APP_PORT,
|
port: process.env.APP_PORT,
|
||||||
relayerServiceFee: Number(process.env.RELAYER_FEE)
|
relayerServiceFee: Number(process.env.RELAYER_FEE)
|
||||||
}
|
}
|
@ -1,18 +0,0 @@
|
|||||||
version: '2.2'
|
|
||||||
|
|
||||||
services:
|
|
||||||
relayer:
|
|
||||||
build: ../../
|
|
||||||
restart: always
|
|
||||||
environment:
|
|
||||||
NODE_ENV: production
|
|
||||||
VIRTUAL_HOST: kovan.tornado.cash
|
|
||||||
LETSENCRYPT_HOST: kovan.tornado.cash
|
|
||||||
env_file: ./.env
|
|
||||||
healthcheck:
|
|
||||||
test: curl -sS http://127.0.0.1:8000 || exit 1
|
|
||||||
|
|
||||||
networks:
|
|
||||||
default:
|
|
||||||
external:
|
|
||||||
name: frontend_default
|
|
@ -1,18 +0,0 @@
|
|||||||
version: '2.2'
|
|
||||||
|
|
||||||
services:
|
|
||||||
relayer:
|
|
||||||
build: ../../
|
|
||||||
restart: always
|
|
||||||
environment:
|
|
||||||
NODE_ENV: production
|
|
||||||
VIRTUAL_HOST: mainnet.tornado.cash
|
|
||||||
LETSENCRYPT_HOST: mainnet.tornado.cash
|
|
||||||
env_file: ./.env
|
|
||||||
healthcheck:
|
|
||||||
test: curl -sS http://127.0.0.1:8000 || exit 1
|
|
||||||
|
|
||||||
networks:
|
|
||||||
default:
|
|
||||||
external:
|
|
||||||
name: frontend_default
|
|
@ -2,9 +2,9 @@
|
|||||||
"name": "relay",
|
"name": "relay",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "Relayer for Tornado mixer. https://tornado.cash",
|
"description": "Relayer for Tornado mixer. https://tornado.cash",
|
||||||
"main": "src/index.js",
|
"main": "app.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node src/index.js",
|
"start": "node app.js",
|
||||||
"eslint": "npx eslint --ignore-path .gitignore .",
|
"eslint": "npx eslint --ignore-path .gitignore .",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
|
@ -38,22 +38,27 @@ class Fetcher {
|
|||||||
}
|
}
|
||||||
async fetchGasPrice({ oracleIndex = 0 } = {}) {
|
async fetchGasPrice({ oracleIndex = 0 } = {}) {
|
||||||
oracleIndex = (oracleIndex + 1) % gasOracleUrls.length
|
oracleIndex = (oracleIndex + 1) % gasOracleUrls.length
|
||||||
|
const url = gasOracleUrls[oracleIndex]
|
||||||
|
const delimiter = url === 'https://ethgasstation.info/json/ethgasAPI.json' ? 10 : 1
|
||||||
try {
|
try {
|
||||||
const response = await fetch(gasOracleUrls[oracleIndex])
|
const response = await fetch(url)
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
const json = await response.json()
|
const json = await response.json()
|
||||||
|
if (Number(json.fast) === 0) {
|
||||||
|
throw new Error('Fetch gasPrice failed')
|
||||||
|
}
|
||||||
|
|
||||||
if (json.slow) {
|
if (json.slow) {
|
||||||
this.gasPrices.low = Number(json.slow)
|
this.gasPrices.low = Number(json.slow) / delimiter
|
||||||
}
|
}
|
||||||
if (json.safeLow) {
|
if (json.safeLow) {
|
||||||
this.gasPrices.low = Number(json.safeLow)
|
this.gasPrices.low = Number(json.safeLow) / delimiter
|
||||||
}
|
}
|
||||||
if (json.standard) {
|
if (json.standard) {
|
||||||
this.gasPrices.standard = Number(json.standard)
|
this.gasPrices.standard = Number(json.standard) / delimiter
|
||||||
}
|
}
|
||||||
if (json.fast) {
|
if (json.fast) {
|
||||||
this.gasPrices.fast = Number(json.fast)
|
this.gasPrices.fast = Number(json.fast) / delimiter
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw Error('Fetch gasPrice failed')
|
throw Error('Fetch gasPrice failed')
|
||||||
|
@ -25,7 +25,7 @@ app.use(function(req, res, next) {
|
|||||||
|
|
||||||
app.get('/', function (req, res) {
|
app.get('/', function (req, res) {
|
||||||
// just for testing purposes
|
// just for testing purposes
|
||||||
res.send('This is <a href=https://tornado.cash>tornado.cash</a> Relayer service. Check the /status for settings')
|
res.send('This is <a href=https://tornado.cash>tornado.cash</a> Relayer service. Check the <a href=/status>/status</a> for settings')
|
||||||
})
|
})
|
||||||
|
|
||||||
app.get('/status', function (req, res) {
|
app.get('/status', function (req, res) {
|
||||||
|
Loading…
Reference in New Issue
Block a user