Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [BUG] - Calling some RPC methods cause the rpc-proxy to crash #1130

Closed
13 tasks
victhorbi opened this issue Aug 2, 2024 · 2 comments · Fixed by #1234
Closed
13 tasks

🐛 [BUG] - Calling some RPC methods cause the rpc-proxy to crash #1130

victhorbi opened this issue Aug 2, 2024 · 2 comments · Fixed by #1234

Comments

@victhorbi
Copy link
Collaborator

victhorbi commented Aug 2, 2024

Here's a list

  • eth_getBlockTransactionCountByNumber
  • eth_getBlockTransactionCountByHash
  • eth_getTransactionByBlockHashAndIndex
  • eth_getTransactionByBlockNumberAndIndex
  • eth_sign
  • eth_getUncleCountByBlockHash
  • eth_getUncleCountByBlockNumber
  • eth_getUncleByBlockHashAndIndex
  • eth_getUncleByBlockNumberAndIndex
  • eth_getProof
  • eth_feeHistory
  • net_peerCount
  • net_listening

Behavior is the following

E.g. 
eth_getBlockTransactionCountByNumber
{
    "jsonrpc":"2.0",
    "method":"eth_getBlockTransactionCountByNumber",
    "params":["0x1707f"],
    "id":1
}
/Users/victorbibiano/node_modules/express/lib/response.js:1159
    : JSON.stringify(value);
           ^

TypeError: Converting circular structure to JSON
    --> starting at object with constructor '_ThorClient'
    |     property 'accounts' -> object with constructor 'AccountsModule'
    --- property 'thor' closes the circle
    at JSON.stringify (<anonymous>)
    at stringify (/Users/victorbibiano/node_modules/express/lib/response.js:1159:12)
    at ServerResponse.json (/Users/victorbibiano/node_modules/express/lib/response.js:272:14)
    at /Users/victorbibiano/node_modules/@vechain/sdk-rpc-proxy/dist/index.js:48449:13
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v18.16.0
@leszek-vechain
Copy link
Collaborator

for eth_getBlockTransactionCountByNumber it seems like the problem is in handleRequest method in rpc-proxy:

            } catch (e) {
                console.log(e);
                res.json({
                    jsonrpc: '2.0',
                    error: e,
                    id: requestBody.id
                });

This method call returns FunctionNotImplemented error:

Debugger attached.
[rpc-proxy]: Starting VeChain RPC Proxy
[rpc-proxy]: Proxy is running on port 8545
FunctionNotImplemented [Error]: Method 'eth_getBlockTransactionCountByNumber' failed.
-Reason: 'Method "eth_getBlockTransactionCountByNumber" has not been implemented yet.'
-Parameters: 
        {"functionName":"eth_getBlockTransactionCountByNumber","thorClient":{"accounts":{},"nodes":{},"blocks":{"headBlock":null},"logs":{},"transactions":{},"contracts":{},"gas":{},"debug":{},"httpClient":{"timeout":30000,"baseURL":"https://testnet.vechain.org"}},"params":["0xc5043f"]}
-Internal error: 
        No internal error given
    at ethGetBlockTransactionCountByNumber (/Users/leszek/IdeaProjects/vechain-sdk-js/packages/network/dist/index.js:5749:9)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.eth_getBlockTransactionCountByNumber (/Users/leszek/IdeaProjects/vechain-sdk-js/packages/network/dist/index.js:5072:7)
    at async VeChainProvider.request (/Users/leszek/IdeaProjects/vechain-sdk-js/packages/network/dist/index.js:6514:12)
    at <anonymous> (/Users/leszek/IdeaProjects/vechain-sdk-js/packages/rpc-proxy/src/index.ts:122:32) {
  methodName: 'eth_getBlockTransactionCountByNumber',
  errorMessage: 'Method "eth_getBlockTransactionCountByNumber" has not been implemented yet.',
  data: {
    functionName: 'eth_getBlockTransactionCountByNumber',
    thorClient: _ThorClient {
      accounts: [AccountsModule],
      nodes: [NodesModule],
      blocks: [BlocksModule],
      logs: [LogsModule],
      transactions: [TransactionsModule],
      contracts: [ContractsModule],
      gas: [GasModule],
      debug: [DebugModule],
      httpClient: [HttpClient]
    },
    params: [ '0xc5043f' ]
  },
  innerError: undefined
}

It seems we are trying to convert this error to fit into res.json, guess we will need to add some tests around it for sure

@leszek-vechain
Copy link
Collaborator

I did try with rest of the RPC calls and it seems it is same issue with all of them (not implemented)

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

Successfully merging a pull request may close this issue.

4 participants