From d04480a62f516dd33b23ca1f6213642dcd092bb7 Mon Sep 17 00:00:00 2001 From: Theo Date: Thu, 7 Sep 2023 10:48:28 -0700 Subject: [PATCH] Update tornado-oracles to fetch gas price and limit only once --- package.json | 4 ++-- src/worker.js | 17 +++++++++++------ yarn.lock | 8 ++++---- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 60ea2c1..f7b4143 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "relay", - "version": "5.2.0", + "version": "5.2.1", "description": "Relayer for Tornado.cash privacy solution. https://tornado.cash", "scripts": { "server": "node src/server.js", @@ -17,7 +17,7 @@ "author": "tornado.cash", "license": "MIT", "dependencies": { - "@tornado/tornado-oracles": "^2.1.0", + "@tornado/tornado-oracles": "^3.3.0", "ajv": "^6.12.5", "bull": "^3.12.1", "concurrently": "^8.2.0", diff --git a/src/worker.js b/src/worker.js index 3391915..b1756ea 100644 --- a/src/worker.js +++ b/src/worker.js @@ -50,14 +50,16 @@ async function checkTornadoFee({ data }, tx) { const userProvidedFee = toBN(data.args[4]) const { amount, decimals, currency } = getInstance(data.contract) - const relayerDesiredFee = await feeOracle.calculateWithdrawalFeeViaRelayer( - 'relayer_withdrawal', + const relayerDesiredFee = await feeOracle.calculateWithdrawalFeeViaRelayer({ tx, - tornadoServiceFee, + txType: 'relayer_withdrawal', + relayerFeePercent: tornadoServiceFee, currency, amount, decimals, - ) + gasLimit: tx.gasLimit, + gasPrice: tx.gasPrice, + }) console.log( 'user-provided fee, desired fee', @@ -77,9 +79,12 @@ async function getTxObject({ data }) { to: tornadoProxyInstance._address, data: calldata, } - const { gasLimit, gasPrice } = await feeOracle.getGasParams(incompleteTx, 'relayer_withdrawal') + const { gasLimit, gasPrice } = await feeOracle.getGasParams({ + tx: incompleteTx, + txType: 'relayer_withdrawal', + }) - return Object.assign(incompleteTx, { gasLimit, gasPrice }) + return { ...incompleteTx, gasLimit, gasPrice } } async function processJob(job) { diff --git a/yarn.lock b/yarn.lock index 0ba6ff9..6f42c75 100644 --- a/yarn.lock +++ b/yarn.lock @@ -896,10 +896,10 @@ resolved "https://git.tornado.ws/api/packages/tornado-packages/npm/%40tornado%2Ftornado-config/-/2.0.0/tornado-config-2.0.0.tgz#52bbc179ecb2385f71b4d56e060b68e7dd6fb8b4" integrity sha512-7EkpWNfEm34VEOrbLnPpvd/aUJYnA1L+6/qx2fZ/AfmuJFkjSZ18Z4jvVGNY7ktKIhTu3/Tbze+9l3eNueCNIA== -"@tornado/tornado-oracles@^2.1.0": - version "2.1.0" - resolved "https://git.tornado.ws/api/packages/tornado-packages/npm/%40tornado%2Ftornado-oracles/-/2.1.0/tornado-oracles-2.1.0.tgz#2aa0d8c9288992e6d194d4bb28acb37c2035c453" - integrity sha512-Y6FPAGnCvHLWzUnNYgGoOv+X7KY3CF02rRSawataYaLyl+v2ivh7RYZZZ3G/B5hXf+pD3IFeCdm4PDnTNyNe1g== +"@tornado/tornado-oracles@^3.3.0": + version "3.3.0" + resolved "https://git.tornado.ws/api/packages/tornado-packages/npm/%40tornado%2Ftornado-oracles/-/3.3.0/tornado-oracles-3.3.0.tgz#6358f896f399904ed8deb9b8f4253e77732bd227" + integrity sha512-OBJ+TmygY6VMcYJCPxSOAzPDZpmF4WhRVhjgTEhqw+hg70WW9L4b3DC1B1P/4Gmar2lzi6BnTI4ckkDy/xsHQQ== dependencies: "@tornado/gas-price-oracle" "^0.5.3" "@tornado/tornado-config" "^2.0.0"