Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

web3.eth.currentProvider.send() Hangs, Missing Data when Iterating through 'Transaction Traces' in a Local Parity Archive Node #3193

@keennay

Description

@keennay

web3.eth.currentProvider.send() Hangs, Missing Data when Iterating through 'Transaction Traces' in a Local Parity Archive Node

Versions

  • OS: Ubuntu 18.04.2 LTS
  • web3.js: v1.2.2
  • Node.js: v10.17.0
  • Ethereum Node: Parity v2.6.4-beta

Expected behavior

Hi, I'm using web3js to iterate through 'Transaction Traces' in a local Parity archive node, specifically the web3.eth.currentProvider.send() function, while passing the correct "trace_transaction" parameters via JSONRPC to Parity. The end goal is to record & index contract calls to a DB. Somewhere in my code, the web3.eth.currentProvider.send() functions are not passing through, and as a result I'm seeing a fraction of Contract Calls in each block instead of 100% of the data.

At first I'd though there was a communication issue between web3js & the local Parity node, so I then simplified the code to only call the web3.eth.currentProvider.send() function twice.

Below is what I expected to see in console:

Transaction Trace #1

transactionHash 0x4142d213b4de56d872b26f9f1955f75bc8d9bd32bdfdb85bbf13455b8dcbd6db
blockNumber: 4754946
addrFrom: 0x8d12a197cb00d4747a1fe03395095ce2a5cc6819
addrTo: 0x9b7e2697d1a213fc00162f7b453b64347186d367
value: 5.9

Transaction Trace #2

transactionHash 0x83c14a4199095e293b81f0ee58f1212dde6f74f577ba52344ad6c3b0d6dff29a
blockNumber: 4754946
addrFrom: 0x8d12a197cb00d4747a1fe03395095ce2a5cc6819
addrTo: 0xea860b5328218a238834bcecd613bb81ec29dccd
value: 3

Actual behavior

Only one of the Transaction Traces is showing up in console. However if I were to comment out the 2nd web3.eth.currentProvider.send() function, I'm able to see the results from the 1st function, and the same applies when commenting out the 1st function: I'll be able to see the 2nd.

Is there a proper method of calling web3.eth.currentProvider.send() to display both functions? This becomes a bigger problem if, let's say, I ran everything in a loop from for ex: Blocks '7 million' through '8 million', as not all contract calls will properly show. Or perhaps am I better off passing the JSON parameters outside of web3.eth.currentProvider.send() via a 3rd party CURL command or another method within Node.js, then storing the data from there?

Steps to reproduce the behavior

Below is the code to reproduce everything, assuming you're running a local Parity archive node. Just change '/parity/mainnet/jsonrpc.ipc' to your proper IPC path.

Here are the commands I'm using for my local Parity node with Tracing enabled, which'll allow me to access Parity's debug functions of iterating through contract calls:

parity --pruning=archive --tracing=on --fat-db=on --db-path=/parity/mainnet --ipc-path=/parity/mainnet/jsonrpc.ipc

Node.js Code:

const net = require('net');
const Web3 = require('web3');
const web3 = new Web3('/parity/mainnet/jsonrpc.ipc', net);

console.log('Transaction Trace #1\n');

web3.eth.currentProvider.send({
    method: "trace_transaction",
    params: ['0x4142d213b4de56d872b26f9f1955f75bc8d9bd32bdfdb85bbf13455b8dcbd6db'],
    id: "2",
    jsonrpc: "2.0"
}, function (err, result) {
    if (err) throw err;
    if (result.result.length > 1) {
        if (result.result[0].type == 'call') {
            for (let i = 1; i < result.result.length; i++) {
               
                if (result.result[i].type == 'call') {
                    var addrFrom = result.result[i].action.from
                    var addrTo = result.result[i].action.to
                    var value = web3.utils.fromWei(result.result[i].action.value,'ether');

		    console.log('transactionHash', result.result[i].transactionHash);
		    console.log('blockNumber:', result.result[i].blockNumber);
		    console.log('addrFrom:', addrFrom);
		    console.log('addrTo:', addrTo);
		    console.log('value:', value);
		    console.log('\n');
                }     
            }
        }
    };
});

console.log('Transaction Trace #2\n');

web3.eth.currentProvider.send({
    method: "trace_transaction",
    params: ['0x83c14a4199095e293b81f0ee58f1212dde6f74f577ba52344ad6c3b0d6dff29a'],
    id: "2",
    jsonrpc: "2.0"
}, function (err, result) {
    if (err) throw err;
    if (result.result.length > 1) {
        if (result.result[0].type == 'call') {
            for (let i = 1; i < result.result.length; i++) {
               
                if (result.result[i].type == 'call') {
                    var addrFrom = result.result[i].action.from
                    var addrTo = result.result[i].action.to
                    var value = web3.utils.fromWei(result.result[i].action.value,'ether');

		    console.log('transactionHash', result.result[i].transactionHash);
		    console.log('blockNumber:', result.result[i].blockNumber);
		    console.log('addrFrom:', addrFrom);
		    console.log('addrTo:', addrTo);
		    console.log('value:', value);
		    console.log('\n');
                }     
            }
        }
    };
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions