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

provider.getBlock('pending') throws error 'invalid hash' #2225

Closed
mjpowersjr opened this issue Oct 26, 2021 · 4 comments
Closed

provider.getBlock('pending') throws error 'invalid hash' #2225

mjpowersjr opened this issue Oct 26, 2021 · 4 comments
Labels
enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published.

Comments

@mjpowersjr
Copy link

Describe the bug
When attempting to fetch the current pending block, ethers result validation rules seem to get tripped up for the current pending block. I've tried this with a few different providers with the same result.

Reproduction steps

provider.getBlock('pending')

"failed to meet quorum (method=\"getBlock\", params={\"includeTransactions\":false,\"blockTag\":\"pending\"}, results=[{\"weight\":1,\"start\":1635252825001,\"error\":{\"reason\":\"invalid hash\",\"code\":\"INVALID_ARGUMENT\",\"argument\":\"value\",\"value\":null,\"checkKey\":\"hash\",\"checkValue\":null}},{\"weight\":1,\"start\":1635252825001,\"error\":{\"reason\":\"invalid hash\",\"code\":\"INVALID_ARGUMENT\",\"argument\":\"value\",\"value\":null,\"checkKey\":\"hash\",\"checkValue\":null}},{\"weight\":1,\"start\":1635252827001,\"error\":{\"reason\":\"invalid hash\",\"code\":\"INVALID_ARGUMENT\",\"argument\":\"value\",\"value\":null,\"checkKey\":\"hash\",\"checkValue\":null}},{\"weight\":1,\"start\":1635252827001,\"error\":{\"reason\":\"invalid hash\",\"code\":\"INVALID_ARGUMENT\",\"argument\":\"value\",\"value\":null,\"checkKey\":\"hash\",\"checkValue\":null}},{\"weight\":1,\"start\":1635252829001,\"error\":{\"reason\":\"invalid hash\",\"code\":\"INVALID_ARGUMENT\",\"argument\":\"value\",\"value\":null,\"checkKey\":\"hash\",\"checkValue\":null}}], provider={\"_isProvider\":true,\"_events\":[],\"_emitted\":{\"block\":-2},\"formatter\":{\"formats\":{\"transaction\":{},\"transactionRequest\":{},\"receiptLog\":{},\"receipt\":{},\"block\":{},\"blockWithTransactions\":{},\"filter\":{},\"filterLog\":{}}},\"anyNetwork\":false,\"_network\":{\"name\":\"homestead\",\"chainId\":1,\"ensAddress\":\"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e\"},\"_maxInternalBlockNumber\":13493120,\"_lastBlockNumber\":-2,\"_pollingInterval\":4000,\"_fastQueryDate\":1635252825000,\"providerConfigs\":[{\"provider\":{\"_isProvider\":true,\"_events\":[],\"_emitted\":{\"block\":-2},\"formatter\":{\"formats\":{\"transaction\":{},\"transactionRequest\":{},\"receiptLog\":{},\"receipt\":{},\"block\":{},\"blockWithTransactions\":{},\"filter\":{},\"filterLog\":{}}},\"anyNetwork\":false,\"_network\":{\"name\":\"homestead\",\"chainId\":1,\"ensAddress\":\"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e\"},\"_maxInternalBlockNumber\":-1024,\"_lastBlockNumber\":-2,\"_pollingInterval\":4000,\"_fastQueryDate\":0,\"connection\":{\"allowGzip\":true,\"url\":\"https://mainnet.infura.io/v3/84842078b09946638c03157f83405213\"},\"_nextId\":43,\"apiKey\":\"84842078b09946638c03157f83405213\",\"projectId\":\"84842078b09946638c03157f83405213\",\"projectSecret\":null},\"weight\":1,\"stallTimeout\":2000,\"priority\":1},{\"provider\":{\"_isProvider\":true,\"_events\":[],\"_emitted\":{\"block\":-2},\"formatter\":{\"formats\":{\"transaction\":{},\"transactionRequest\":{},\"receiptLog\":{},\"receipt\":{},\"block\":{},\"blockWithTransactions\":{},\"filter\":{},\"filterLog\":{}}},\"anyNetwork\":false,\"_network\":{\"name\":\"homestead\",\"chainId\":1,\"ensAddress\":\"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e\"},\"_maxInternalBlockNumber\":13493120,\"_lastBlockNumber\":-2,\"_pollingInterval\":4000,\"_fastQueryDate\":1635252824903,\"baseUrl\":\"https://api.etherscan.io\",\"apiKey\":\"9D13ZE7XSBTJ94N9BNJ2MA33VMAY2YPIRB\",\"_internalBlockNumber\":{},\"_fastBlockNumber\":13493120,\"_fastBlockNumberPromise\":{}},\"weight\":1,\"stallTimeout\":2000,\"priority\":1},{\"provider\":{\"_isProvider\":true,\"_events\":[],\"_emitted\":{\"block\":-2},\"formatter\":{\"formats\":{\"transaction\":{},\"transactionRequest\":{},\"receiptLog\":{},\"receipt\":{},\"block\":{},\"blockWithTransactions\":{},\"filter\":{},\"filterLog\":{}}},\"anyNetwork\":false,\"_network\":{\"name\":\"homestead\",\"chainId\":1,\"ensAddress\":\"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e\"},\"_maxInternalBlockNumber\":-1024,\"_lastBlockNumber\":-2,\"_pollingInterval\":4000,\"_fastQueryDate\":0,\"connection\":{\"allowGzip\":true,\"url\":\"https://eth-mainnet.alchemyapi.io/v2/_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC\"},\"_nextId\":43,\"apiKey\":\"_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC\"},\"weight\":1,\"stallTimeout\":2000,\"priority\":1},{\"provider\":{\"_isProvider\":true,\"_events\":[],\"_emitted\":{\"block\":-2},\"formatter\":{\"formats\":{\"transaction\":{},\"transactionRequest\":{},\"receiptLog\":{},\"receipt\":{},\"block\":{},\"blockWithTransactions\":{},\"filter\":{},\"filterLog\":{}}},\"anyNetwork\":false,\"_network\":{\"name\":\"homestead\",\"chainId\":1,\"ensAddress\":\"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e\"},\"_maxInternalBlockNumber\":13493120,\"_lastBlockNumber\":-2,\"_pollingInterval\":4000,\"_fastQueryDate\":1635252825000,\"connection\":{\"url\":\"https://eth-mainnet.gateway.pokt.network/v1/lb/6004bcd10040261633ade990\",\"headers\":{}},\"_nextId\":44,\"applicationId\":\"6004bcd10040261633ade990\",\"loadBalancer\":true,\"applicationSecretKey\":null,\"_eventLoopCache\":{\"eth_blockNumber\":null},\"_internalBlockNumber\":{},\"_fastBlockNumber\":13493120,\"_fastBlockNumberPromise\":{}},\"weight\":1,\"stallTimeout\":2000,\"priority\":1},{\"provider\":{\"_isProvider\":true,\"_events\":[],\"_emitted\":{\"block\":-2},\"formatter\":{\"formats\":{\"transaction\":{},\"transactionRequest\":{},\"receiptLog\":{},\"receipt\":{},\"block\":{},\"blockWithTransactions\":{},\"filter\":{},\"filterLog\":{}}},\"anyNetwork\":false,\"_network\":{\"name\":\"homestead\",\"chainId\":1,\"ensAddress\":\"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e\"},\"_maxInternalBlockNumber\":-1024,\"_lastBlockNumber\":-2,\"_pollingInterval\":4000,\"_fastQueryDate\":0,\"connection\":{\"url\":\"https://cloudflare-eth.com/\"},\"_nextId\":43},\"weight\":1,\"stallTimeout\":750,\"priority\":1}],\"quorum\":2,\"_highestBlockNumber\":13493120,\"_internalBlockNumber\":{},\"_fastBlockNumber\":13493120,\"_fastBlockNumberPromise\":{}}, code=SERVER_ERROR, version=providers/5.4.5)"

Environment:
This can be reproduced in the online playground & Node.js environments.

@mjpowersjr mjpowersjr added the investigate Under investigation and may be a bug. label Oct 26, 2021
@zemse
Copy link
Collaborator

zemse commented Oct 31, 2021

Can be reproduced with:

await new providers.InfuraProvider().getBlock('pending');

The hash field from the JSON RPC is null for a pending block

@coffee-git
Copy link

coffee-git commented Dec 11, 2021

same here

hash and miner fields can be null in pending block, just add for them Formatter.allowNull in formatter.ts getDefaultFormats

#2023

@ricmoo ricmoo added enhancement New feature or improvement. minor-bump Planned for the next minor version bump. on-deck This Enhancement or Bug is currently being worked on. and removed investigate Under investigation and may be a bug. labels Feb 19, 2022
ricmoo added a commit that referenced this issue Mar 9, 2022
@ricmoo
Copy link
Member

ricmoo commented Mar 10, 2022

This should now be supported in v5.6.

Please try it out and let me know if you still have any problems. :)

@ricmoo ricmoo added fixed/complete This Bug is fixed or Enhancement is complete and published. and removed on-deck This Enhancement or Bug is currently being worked on. minor-bump Planned for the next minor version bump. labels Mar 10, 2022
@ricmoo
Copy link
Member

ricmoo commented Mar 17, 2022

This was added, so I'll close it. Please re-open or create a new issue if there are any problems.

Thanks! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published.
Projects
None yet
Development

No branches or pull requests

4 participants