You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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:
Hey @nivida, I think I figured out my issue. It has more to do with my lack of understanding how POST requests work, as the "id" tag has to be unique with each interaction. Thankfully I can just fill this out with the 'transactionHash' variable & pass that value into a new function for each transaction call.
const net = require('net');
const Web3 = require('web3');
const web3 = new Web3('/parity/mainnet/jsonrpc.ipc', net);
console.log('Transaction Trace #1\n');
getTransactionTrace(0x4142d213b4de56d872b26f9f1955f75bc8d9bd32bdfdb85bbf13455b8dcbd6db);
console.log('Transaction Trace #2\n');
getTransactionTrace(0x83c14a4199095e293b81f0ee58f1212dde6f74f577ba52344ad6c3b0d6dff29a);
function getTransactionTrace(transactionHash) {
web3.eth.currentProvider.send({
method: "trace_transaction",
params: [transactionHash],
id: transactionHash,
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');
}
}
}
};
});
};
web3.eth.currentProvider.send() Hangs, Missing Data when Iterating through 'Transaction Traces' in a Local Parity Archive Node
Versions
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:
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:
The text was updated successfully, but these errors were encountered: