vechain / vechain-sdk-js

The official JavaScript SDK for VeChain.
19 stars 6 forks source link

🐛 [BUG] - `eth_getTransactionCount` returns random numbers #942

Open ifavo opened 1 month ago

ifavo commented 1 month ago

Description

When accessing eth_getTransactionCount on the RPC Mapper, there is a random number returned at all times.

https://github.com/vechain/vechain-sdk-js/blob/630d4028096de84d82ea2176985c086cfd9acb03/packages/network/src/provider/utils/rpc-mapper/methods-map/methods/eth_getTransactionCount/eth_getTransactionCount.ts#L46

This might be sufficient for applications using only the number or for test cases, but not for applications relying on the counter, like hardhat-ignition does.

For example hardhat-ignition fails to interact with vechain networks, because it detects pending transactions that do not exist.

I suggest to:

  1. Either return 0 at all times or return the current block number
  2. and add Transaction Pool and filter for the request address, to return a meaningful number in the pending request

As reference, here are requests within ignition that result in invalid conditions:

https://github.com/NomicFoundation/hardhat-ignition/blob/development/packages/core/src/internal/execution/nonce-management/get-nonce-sync-messages.ts#L89-L112

Reproduction URL

No response

Reproduction steps

curl -s https://rpc-testnet.vechain.energy/ \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{"method":"eth_getTransactionCount","params":["0x202bB937Af984F83184B726cDc099A76d8bcDE8b", "pending"],"id":1,"jsonrpc":"2.0"}' | jq

Returns a value, even if there is nothing pending:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0x53aebba70699"
}

Screenshots

![DESCRIPTION](LINK.png)

Logs

No response

OS

No response