5

I have a very similar problem as https://github.com/paritytech/parity-ethereum/issues/8788

When I use web3.eth.getBlock for the first 1 million and latest 50,000 blocks (approximately), I get the desired output, while for blocks number 1,000,000 to latest-50,000 it returns null.

I'm using Parity v1.10.8-stable on Windows 10. My node is connected to Ethereum mainnet and fully synchronized. web3 version 0.20.6.

Is this a bug and I can't do anything or can it be fixed?

My script:

const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")); 

const run  = async () => {
    const latestBlock = 6039000
    console.log('+100', !!(await web3.eth.getBlock(100)))
    console.log('+1000', !!(await web3.eth.getBlock(1000)))
    console.log('+10000', !!(await web3.eth.getBlock(10000)))
    console.log('+100000', !!(await web3.eth.getBlock(100000)))
    console.log('+1000000', !!(await web3.eth.getBlock(100000)))
    console.log('+2500000', !!(await web3.eth.getBlock(2500000)))
    console.log('-2500000', !!(await web3.eth.getBlock(latestBlock-2500000)))
    console.log('-1000000', !!(await web3.eth.getBlock(latestBlock-100000)))
    console.log('-100000', !!(await web3.eth.getBlock(latestBlock-100000)))
    console.log('-10000', !!(await web3.eth.getBlock(latestBlock-10000)))
    console.log('-1000', !!(await web3.eth.getBlock(latestBlock-1000)))
    console.log('-100', !!(await web3.eth.getBlock(latestBlock-100)))
}

run()

Output:

+100 true
+1000 true
+10000 true
+100000 true
+1000000 true
+2500000 false
-2500000 false
-1000000 false
-100000 false
-10000 true
-1000 true
-100 true

1 Answer 1

0

This just means that the block is in a pending state.

This could be so because your node is not up to speed with the blockchain.

If you are wanting to get the latest available block number, use getBlockNumber.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.