update proxy
This commit is contained in:
parent
80f9d4017f
commit
5d4ae5965c
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "relay",
|
||||
"version": "4.0.9",
|
||||
"version": "4.0.10",
|
||||
"description": "Relayer for Tornado.cash privacy solution. https://tornado.cash",
|
||||
"scripts": {
|
||||
"server": "node src/server.js",
|
||||
@ -29,8 +29,8 @@
|
||||
"gas-price-oracle": "^0.2.2",
|
||||
"ioredis": "^4.14.1",
|
||||
"node-fetch": "^2.6.0",
|
||||
"torn-token": "1.0.3",
|
||||
"tornado-cash-anonymity-mining": "^1.0.0",
|
||||
"torn-token": "1.0.4",
|
||||
"tornado-anonymity-mining": "^2.1.2",
|
||||
"tx-manager": "^0.2.9",
|
||||
"uuid": "^8.3.0",
|
||||
"web3": "^1.3.0",
|
||||
|
@ -18,11 +18,11 @@ module.exports = {
|
||||
tornadoServiceFee: Number(process.env.REGULAR_TORNADO_WITHDRAW_FEE),
|
||||
miningServiceFee: Number(process.env.MINING_SERVICE_FEE),
|
||||
rewardAccount: process.env.REWARD_ACCOUNT,
|
||||
tornadoGoerliProxy: '0x454d870a72e29d5E5697f635128D18077BD04C60',
|
||||
gasLimits: {
|
||||
[jobType.TORNADO_WITHDRAW]: 350000,
|
||||
[jobType.MINING_REWARD]: 455000,
|
||||
[jobType.MINING_WITHDRAW]: 400000,
|
||||
},
|
||||
tornadoProxy: '0x454d870a72e29d5E5697f635128D18077BD04C60',
|
||||
minimumBalance: '1000000000000000000',
|
||||
}
|
||||
|
@ -2,10 +2,12 @@ const { instances, netId } = require('./config')
|
||||
const { poseidon } = require('circomlib')
|
||||
const { toBN, toChecksumAddress, BN } = require('web3-utils')
|
||||
|
||||
const TORN_TOKEN = {
|
||||
const TOKENS = {
|
||||
torn: {
|
||||
tokenAddress: '0x77777FeDdddFfC19Ff86DB637967013e6C6A116C',
|
||||
symbol: 'TORN',
|
||||
decimals: 18,
|
||||
},
|
||||
}
|
||||
|
||||
const sleep = ms => new Promise(res => setTimeout(res, ms))
|
||||
@ -52,7 +54,7 @@ function when(source, event) {
|
||||
function getArgsForOracle() {
|
||||
const tokens = {
|
||||
...instances.netId1,
|
||||
torn: TORN_TOKEN,
|
||||
...TOKENS,
|
||||
}
|
||||
const tokenAddresses = []
|
||||
const oneUintAmount = []
|
||||
|
@ -1,35 +1,34 @@
|
||||
const fs = require('fs')
|
||||
const Web3 = require('web3')
|
||||
const { toBN, toWei, fromWei } = require('web3-utils')
|
||||
const { toBN, toWei, fromWei, toChecksumAddress } = require('web3-utils')
|
||||
const MerkleTree = require('fixed-merkle-tree')
|
||||
const Redis = require('ioredis')
|
||||
const { GasPriceOracle } = require('gas-price-oracle')
|
||||
const { Utils } = require('tornado-cash-anonymity-mining')
|
||||
const { Utils, Controller } = require('tornado-anonymity-mining')
|
||||
|
||||
const tornadoProxyABI = require('../abis/tornadoProxyABI.json')
|
||||
const tornadoABI = require('../abis/tornadoABI.json')
|
||||
const miningABI = require('../abis/mining.abi.json')
|
||||
const swapABI = require('../abis/swap.abi.json')
|
||||
const miningABI = require('../abis/mining.abi.json')
|
||||
const tornadoABI = require('../abis/tornadoABI.json')
|
||||
const tornadoProxyABI = require('../abis/tornadoProxyABI.json')
|
||||
const { queue } = require('./queue')
|
||||
const { poseidonHash2, getInstance, fromDecimals, sleep } = require('./utils')
|
||||
const { jobType, status } = require('./constants')
|
||||
const {
|
||||
netId,
|
||||
torn,
|
||||
httpRpcUrl,
|
||||
netId,
|
||||
redisUrl,
|
||||
privateKey,
|
||||
gasLimits,
|
||||
instances,
|
||||
privateKey,
|
||||
httpRpcUrl,
|
||||
oracleRpcUrl,
|
||||
tornadoProxy,
|
||||
tornadoServiceFee,
|
||||
miningServiceFee,
|
||||
tornadoServiceFee,
|
||||
tornadoGoerliProxy,
|
||||
} = require('./config')
|
||||
const ENSResolver = require('./resolver')
|
||||
const resolver = new ENSResolver()
|
||||
const { TxManager } = require('tx-manager')
|
||||
const { Controller } = require('tornado-cash-anonymity-mining')
|
||||
|
||||
let web3
|
||||
let currentTx
|
||||
@ -39,7 +38,6 @@ let txManager
|
||||
let controller
|
||||
let swap
|
||||
let minerContract
|
||||
let proxyContract
|
||||
const redis = new Redis(redisUrl)
|
||||
const redisSubscribe = new Redis(redisUrl)
|
||||
const gasPriceOracle = new GasPriceOracle({ defaultRpc: oracleRpcUrl })
|
||||
@ -85,14 +83,6 @@ async function start() {
|
||||
})
|
||||
swap = new web3.eth.Contract(swapABI, await resolver.resolve(torn.rewardSwap.address))
|
||||
minerContract = new web3.eth.Contract(miningABI, await resolver.resolve(torn.miningV2.address))
|
||||
if (netId === 5) {
|
||||
proxyContract = new web3.eth.Contract(tornadoProxyABI, tornadoProxy)
|
||||
} else {
|
||||
proxyContract = new web3.eth.Contract(
|
||||
tornadoProxyABI,
|
||||
await resolver.resolve(torn.tornadoProxy.address),
|
||||
)
|
||||
}
|
||||
redisSubscribe.subscribe('treeUpdate', fetchTree)
|
||||
await fetchTree()
|
||||
const provingKeys = {
|
||||
@ -184,16 +174,37 @@ async function checkMiningFee({ args }) {
|
||||
}
|
||||
}
|
||||
|
||||
function getTxObject({ data }) {
|
||||
async function getProxyContract() {
|
||||
let proxyAddress = await resolver.resolve(torn.tornadoProxy.address)
|
||||
|
||||
if (netId === 5) {
|
||||
proxyAddress = tornadoGoerliProxy
|
||||
}
|
||||
|
||||
const contract = new web3.eth.Contract(tornadoProxyABI, proxyAddress)
|
||||
|
||||
return {
|
||||
contract,
|
||||
isOldProxy: checkOldProxy(proxyAddress),
|
||||
}
|
||||
}
|
||||
|
||||
function checkOldProxy(address) {
|
||||
const OLD_PROXY = '0x905b63Fff465B9fFBF41DeA908CEb12478ec7601'
|
||||
return toChecksumAddress(address) === OLD_PROXY
|
||||
}
|
||||
|
||||
async function getTxObject({ data }) {
|
||||
if (data.type === jobType.TORNADO_WITHDRAW) {
|
||||
let contract, calldata
|
||||
if (getInstance(data.contract).currency === 'eth') {
|
||||
contract = proxyContract
|
||||
calldata = contract.methods.withdraw(data.contract, data.proof, ...data.args).encodeABI()
|
||||
} else {
|
||||
let { contract, isOldProxy } = await getProxyContract()
|
||||
|
||||
let calldata = contract.methods.withdraw(data.contract, data.proof, ...data.args).encodeABI()
|
||||
|
||||
if (isOldProxy && getInstance(data.contract).currency !== 'eth') {
|
||||
contract = new web3.eth.Contract(tornadoABI, data.contract)
|
||||
calldata = contract.methods.withdraw(data.proof, ...data.args).encodeABI()
|
||||
}
|
||||
|
||||
return {
|
||||
value: data.args[5],
|
||||
to: contract._address,
|
||||
@ -241,7 +252,7 @@ async function processJob(job) {
|
||||
|
||||
async function submitTx(job, retry = 0) {
|
||||
await checkFee(job)
|
||||
currentTx = await txManager.createTx(getTxObject(job))
|
||||
currentTx = await txManager.createTx(await getTxObject(job))
|
||||
|
||||
if (job.data.type !== jobType.TORNADO_WITHDRAW) {
|
||||
await fetchTree()
|
||||
|
Loading…
Reference in New Issue
Block a user