Estimate gas to check possibly revert of invalid transaction that relayer don't spend gas accidentally
This commit is contained in:
parent
8ebcfe6b55
commit
89367a8b43
@ -30,6 +30,7 @@ const {
|
|||||||
miningServiceFee,
|
miningServiceFee,
|
||||||
tornadoServiceFee,
|
tornadoServiceFee,
|
||||||
tornadoGoerliProxy,
|
tornadoGoerliProxy,
|
||||||
|
rewardAccount,
|
||||||
} = require('./config')
|
} = require('./config')
|
||||||
const resolver = require('./modules/resolver')
|
const resolver = require('./modules/resolver')
|
||||||
const { TxManager } = require('@tornado/tx-manager')
|
const { TxManager } = require('@tornado/tx-manager')
|
||||||
@ -265,10 +266,20 @@ async function processJob(job) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function checkRevert(tx) {
|
||||||
|
try {
|
||||||
|
await web3.eth.estimateGas(Object.assign({ from: rewardAccount }, tx))
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error('Estimation error: transaction will possibly be reverted')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function submitTx(job, retry = 0) {
|
async function submitTx(job, retry = 0) {
|
||||||
await checkRecipient(job)
|
await checkRecipient(job)
|
||||||
await checkFee(job)
|
await checkFee(job)
|
||||||
currentTx = await txManager.createTx(await getTxObject(job))
|
const tx = await getTxObject(job)
|
||||||
|
await checkRevert(tx)
|
||||||
|
currentTx = await txManager.createTx(tx)
|
||||||
|
|
||||||
if (job.data.type !== jobType.TORNADO_WITHDRAW) {
|
if (job.data.type !== jobType.TORNADO_WITHDRAW) {
|
||||||
await fetchTree()
|
await fetchTree()
|
||||||
|
Loading…
Reference in New Issue
Block a user