Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Connection timeout sending transaction with CURL but not error output #4338

Closed
MatthieuScarset opened this issue Apr 1, 2023 · 9 comments
Closed

Comments

@MatthieuScarset
Copy link
Contributor

MatthieuScarset commented Apr 1, 2023

Running ganache in verbose mode ganache -v --logging.debug and sending a transaction (see below) ends up in a Connection timeout error but there is no information about what's wrong.

The transaction values are correct because I can send it successfully via another provider (e.g. tested successfully through Alchemy and Metamask).

use kornrunner\Ethereum\EIP1559Transaction;

$nonce = '01';
$maxPriorityFeePerGas = 'b2d05e00';
$maxFeePerGas = '6fc23ac00';
$gasLimit = '5208';
$to = '11d749256d326d3b316C2dcDF2b7d8cE20CF2cFd';
$value = '29a2241af62c0000';
$data = '';
$chainId = 1337;

$privateKey = 'PRIVATEKEY';

$transaction = new EIP1559Transaction($nonce, $maxPriorityFeePerGas, $maxFeePerGas, $gasLimit, $to, $value, $data);
$rawTx = $transaction->getRaw($privateKey, $chainId);

The POST is as follow:

"[{"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":["0x02f8758205390184b2d05e008506fc23ac008252089411d749256d326d3b316C2dcDF2b7d8cE20CF2cFd8829a2241af62c000080c001a0a391210b5e7390bfd9269476a96b354e73290dedc95fc02c056263d133b5ade6a04268d49d2bce109a00052cb1a692401949af77eeb3db939561fd4ec2428752c5"],"id":0}]"

Ganache receives the transaction as I can see it in my terminal but then it timeout after 30001 milliseconds without explanations.
image

Any help will be much appreciated 👋

@jeffsmale90
Copy link
Contributor

jeffsmale90 commented Apr 3, 2023

Thanks @MatthieuScarset for raising this issue. I suspect this is caused by a future-nonce. Can you please check the transaction count of the account you are using with the following:

curl -s http://localhost:8545 -X POST -H "Content-Type:application/json;" -d '{"id":1,"jsonrpc":"2.0","method":"eth_getTransactionCount","params":["0x11d749256d326d3b316C2dcDF2b7d8cE20CF2cFd"]}'

Assuming the transaction count is 0, then you'll need to set the nonce to '00'.

AFAICT this is a problem with Ganache, as it shouldn't fail to return. I feel like there was some work in progress somewhere to address this. I'll have a look tomorrow and see if I can find it.

@jeffsmale90
Copy link
Contributor

In v7.7.6 we added a log to warn users of the future nonce: #4166

If you are running >= v7.7.6 and don't get that warning, then it's likely it's another issue. As to holding the connection open, I'll have to chat with the team to understand the reasoning behind this.

@MatthieuScarset
Copy link
Contributor Author

I forgot to state the version I'm using, sorry. I'm using Ganache 8.19.3 - the latest version as of today.

Thank you for linking the issue #4166. The bug/behavior described in this issue is exactly what I am experiencing.

So either the issue with future nonce is not fixed or it's something else from my transaction's values?

@jeffsmale90
Copy link
Contributor

@MatthieuScarset can you please double check the version - the latest is v7.7.7

@MatthieuScarset
Copy link
Contributor Author

Oups sorry. I run a wrong cmd and it gave me the version of npm itself I think... 😮‍💨

I am using Ganache ^7.7.5 indeed.

Let me try with the latest version to see if I can reproduce the issue or if I have an error returned before timeout.

@MatthieuScarset
Copy link
Contributor Author

MatthieuScarset commented Apr 3, 2023

It fails! 🎉 with an error message.

{"id":null,"jsonrpc":"2.0","error":{"message":"insufficient funds for gas * price + value","stack":"Error: insufficient funds for gas * price + value\n at TransactionPool.prepareTransaction (\/app\/node_modules\/ganache\/dist\/node\/1.js:2:121958)","code":-32003}}

So I now at least know what I need to work on to fix my transaction.

Thank you for your help!

@jeffsmale90
Copy link
Contributor

Excellent - let us know if you have any more challenges with Ganache.

Cheers!

@davidmurdoch
Copy link
Member

@MatthieuScarset, we've got a feature branch that, upon start up, logs a message to the console that ganache is out of date and you should update. It would look similar to this message:

image

The message is only logged once for each new version we release.

If ganache had this (optional, opt-out) feature do you think you would have updated?

@MatthieuScarset
Copy link
Contributor Author

I would certainly have updated, yes. It's a side project i'm working on so I don't fear to break things... I would try to keep all dependencies the most up to date possible.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants