Update the condition for checking if a tx was stuck (#444)
This commit is contained in:
parent
dc377aeb9b
commit
4e04f2ae1f
@ -123,38 +123,32 @@ async function main({ msg, ackMsg, nackMsg, channel, scheduleForRetry, scheduleT
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let txNonce
|
|
||||||
if (isResend) {
|
if (isResend) {
|
||||||
const tx = await web3Instance.eth.getTransaction(job.txHash)
|
const tx = await web3Instance.eth.getTransaction(job.txHash)
|
||||||
|
|
||||||
if (tx === null) {
|
if (tx && tx.blockNumber !== null) {
|
||||||
logger.info(`Transaction ${job.txHash} was not found, dropping it`)
|
logger.debug(`Transaction ${job.txHash} was successfully mined`)
|
||||||
return
|
|
||||||
}
|
|
||||||
if (tx.blockNumber !== null) {
|
|
||||||
logger.info(`Transaction ${job.txHash} was successfully mined`)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
`Previously sent transaction is stuck, updating gasPrice: ${tx.gasPrice} -> ${gasPrice.toString(10)}`
|
`Previously sent transaction is stuck, updating gasPrice: ${job.gasPrice} -> ${gasPrice.toString(10)}`
|
||||||
)
|
)
|
||||||
if (toBN(tx.gasPrice).gte(toBN(gasPrice))) {
|
if (toBN(job.gasPrice).gte(toBN(gasPrice))) {
|
||||||
logger.info("Gas price returned from the oracle didn't increase, will reinspect this transaction later")
|
logger.info("Gas price returned from the oracle didn't increase, will reinspect this transaction later")
|
||||||
sentTx.push(job)
|
sentTx.push(job)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
txNonce = tx.nonce
|
|
||||||
} else {
|
} else {
|
||||||
txNonce = nonce++
|
job.nonce = nonce++
|
||||||
}
|
}
|
||||||
logger.info(`Sending transaction with nonce ${txNonce}`)
|
logger.info(`Sending transaction with nonce ${job.nonce}`)
|
||||||
const txHash = await sendTx({
|
job.gasPrice = gasPrice.toString(10)
|
||||||
|
job.txHash = await sendTx({
|
||||||
chain: config.id,
|
chain: config.id,
|
||||||
data: job.data,
|
data: job.data,
|
||||||
nonce: txNonce,
|
nonce: job.nonce,
|
||||||
gasPrice: gasPrice.toString(10),
|
gasPrice: job.gasPrice,
|
||||||
amount: '0',
|
amount: '0',
|
||||||
gasLimit,
|
gasLimit,
|
||||||
privateKey: ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY,
|
privateKey: ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY,
|
||||||
@ -162,14 +156,11 @@ async function main({ msg, ackMsg, nackMsg, channel, scheduleForRetry, scheduleT
|
|||||||
chainId,
|
chainId,
|
||||||
web3: web3Instance
|
web3: web3Instance
|
||||||
})
|
})
|
||||||
sentTx.push({
|
sentTx.push(job)
|
||||||
...job,
|
|
||||||
txHash
|
|
||||||
})
|
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
{ eventTransactionHash: job.transactionReference, generatedTransactionHash: txHash },
|
{ eventTransactionHash: job.transactionReference, generatedTransactionHash: job.txHash },
|
||||||
`Tx generated ${txHash} for event Tx ${job.transactionReference}`
|
`Tx generated ${job.txHash} for event Tx ${job.transactionReference}`
|
||||||
)
|
)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error(
|
logger.error(
|
||||||
|
Loading…
Reference in New Issue
Block a user