ethers-io / ethers.js

Complete Ethereum library and wallet implementation in JavaScript.
https://ethers.org/
MIT License
7.87k stars 1.82k forks source link

Error in getTransactionReceipt when using light sync client #769

Open achal-singh opened 4 years ago

achal-singh commented 4 years ago

Hi @ricmoo, I am getting the following error when I'm using my own JSON-RPC client, a parity light node, and executing getTransactionReceipt() function, but getTransaction is working absolutely fine with the same provider. zethers const ethers = require('ethers'); const provider = new ethers.providers.JsonRpcProvider( 'http://<MY_PARITY_NODE_IP>:8545' );

(async () => { const a = await provider.getTransactionReceipt( '0x52db3310c90e6c60a35ea8d6b27ee4fa292fcd7700ea15ce0c09495928995bd4' ); console.log(a); })();

Could you please help me with this?

achal-singh commented 4 years ago

I have observed this behavior with parity light and warp sync provider nodes only, but it works perfectly fine with archive nodes. Is there a way to fix it while using the light client?

achal-singh commented 4 years ago

@ricmoo I would really appreciate some help here, as I'm stuck with this issue for quite some days now. Please help. :)

ricmoo commented 4 years ago

I haven’t really dealt much with light nodes. Can you send along the command line parameters you are using? I’ll try to reproduce this tomorrow, but it might be that light nodes don’t actually keep that data on-disk... :s

achal-singh commented 4 years ago
  1. Sure, here's the config.toml file: `[parity] mode = "active" auto_update = "critical" release_track = "current" chain = "foundation" light = true

[network] warp = false allow_ips = "all"

[rpc] disable = false port = 8545 interface = "0.0.0.0" cors = [] apis = ["web3", "eth", "pubsub", "net", "parity", "private", "parity_pubsub", "traces", "rpc", "shh", "shh_pubsub", "signer", "secretstore", "parity_accounts", "personal", "parity_set"] hosts = ["all"] server_threads = 4

processing_threads = 10

[footprint] tracing = "on"

pruning = "fast" pruning_history = 500 pruning_memory = 10000 cache_size_db = 128 cache_size_blocks = 8 cache_size_queue = 40 cache_size_state = 25 cache_size = 128 # Overrides above caches with total size fast_and_loose = false db_compaction = "ssd" fat_db = "auto" scale_verifiers = true num_verifiers = 6

[misc] logging = "own_tx=trace" log_file = "/var/log/parity.log" color = true`

Also, please suggest any changes you might think are necessary to this config file. I'm quite new to setting up parity node and have very limited knowledge about the parameters. I'm executing this parity node inside of a docker container, so the ENTRYPOINT command is: ENTRYPOINT ["/bin/parity", "--jsonrpc-server-threads=8", "--config=/root/.local/share/io.parity.ethereum/config.toml"]

  1. There's another issue I'm facing when I try to call getTransaction, with my custom light node provider, on a block that has over 180 transactions, in the code below this.ethersProvider is the provider instance of my light node: this.ethersProvider.getBlock(blockNumber).then(async res => { const pr = res.transactions.map(hash => this.ethersProvider.getTransaction(hash).then(res => res) ); const txs = await Promise.all(pr); console.log(txs);

The ERROR thrown on my console is this: Error: Bad response on request: [ TransactionIndex ]. Error cause was EmptyResponse, (majority count: 31 / total: 31) at getResult (/home/achal/xhub/blockchain-services/eth/node_modules/ethers/providers/json-rpc-provider.js:40:21) at exports.XMLHttpRequest.request.onreadystatechange (/home/achal/xhub/blockchain-services/eth/node_modules/ethers/utils/web.js:111:30) at exports.XMLHttpRequest.dispatchEvent (/home/achal/xhub/blockchain-services/eth/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:591:25) at setState (/home/achal/xhub/blockchain-services/eth/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:610:14) at IncomingMessage. (/home/achal/xhub/blockchain-services/eth/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:447:13) at emitNone (events.js:111:20) at IncomingMessage.emit (events.js:208:7) at endReadableNT (_stream_readable.js:1064:12) at _combinedTickCallback (internal/process/next_tick.js:139:11) at process._tickCallback (internal/process/next_tick.js:181:9)