AlmostEfficient / FaucetBot

Discord bot that dispenses ETH on EVM testnets
GNU General Public License v3.0
37 stars 17 forks source link

Stalled transactions not properly handled #1

Closed AlmostEfficient closed 3 years ago

AlmostEfficient commented 3 years ago

Area/Action Creating an ETH transaction with the /faucet command

Expected behaviour Transaction sent

Actual behaviour Bot responded like the tx was sent but crashed 750s later.

Description A transaction on the Rinkeby network just stalled. I'm not entirely sure why this happened. Link - https://rinkeby.etherscan.io/tx/0xc431514685d87e2e46724381c349b366d6244d4ab391dae21e21e33a84ec3266

Bot crashed after the promise was resolved.

\node_modules\web3-core-helpers\lib\errors.js:87
        var error = new Error(message);
                    ^
Error: Transaction was not mined within 750 seconds, please make sure your transaction was properly sent. Be aware that it might still be mined!
    at Object.TransactionError (\node_modules\web3-core-helpers\lib\errors.js:87:21)
    at \node_modules\web3-core-method\lib\index.js:416:49
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  receipt: undefined
AlmostEfficient commented 3 years ago

The transaction seems to have vanished into thin air after I sent ETH to the same address via Metamask. Looking like an issue with Alchemy. Will add Infura as an alternative.

AlmostEfficient commented 3 years ago

Switching to Infura did not solve this. Infura was somehow worse, had a higher no. of stalled transactions.

This seems to have been solved by using more gas. I'm adding maxFeePerGas in the tx and setting it to something ridiculous like 95 gwei. Not an ideal solution but I wasn't able to find any other information about this.

Alchemy tx options -

const transaction = {
  'to': toAddress,
  'value': amountInWei,
  'gas': 30000,
  'maxFeePerGas': 95000000000,
  'nonce': nonce,
};

Infura tx options -

const txData = {
  'data': '0x', // Changing this will cost you 4 gas for a zero byte, 68 gas for non-zeros
  'gasLimit': '0x5208', // 21000
  'maxPriorityFeePerGas': 65000000000, // 65 gwei
  'maxFeePerGas': 95000000000, // MUST be higher than maxPriorityFeePerGas
  'nonce': nonce,
  'to': toAddress,
  'value': amountInWei._hex,
  'chainId': '0x04',
  'accessList': [],
  'type': '0x02',
}

Closing it here since I've gone about 400 transactions without a stall after this change.