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

All blocks starting from 13199981 return null on difficult field #2036

Closed
wmitsuda opened this issue Sep 11, 2021 · 5 comments
Closed

All blocks starting from 13199981 return null on difficult field #2036

wmitsuda opened this issue Sep 11, 2021 · 5 comments
Labels
enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published. minor-bump Planned for the next minor version bump.

Comments

@wmitsuda
Copy link

Ethers 5.4.6:

On mainnet, starting from block 13199981, the difficult field always comes with null.

{
  hash: '0x7558a1559758e3dfa1074188285adff74d1f1833a6363f891d6eccebdfd825ed',
  parentHash: '0xecab8888f9fc828d9ae07775de4db8b5104fc120349159835bd5d252dcda1834',
  number: 13199981,
  timestamp: 1631302838,
  nonce: '0x2a59d15c02876925',
  difficulty: null,
  gasLimit: BigNumber { _hex: '0x01c9c380', _isBigNumber: true },

I do confirm that this info comes in the raw response:

{
  "jsonrpc": "2.0",
  "id": 83,
  "result": {
    "baseFeePerGas": "0xed21e880a",
    "difficulty": "0x2003f36c614e37",
    "extraData": "0x486976656f6e2063612d6865617679204c586c67",
    "gasLimit": "0x1c9c380",
    "gasUsed": "0x1c99d15",
    "hash": "0x7558a1559758e3dfa1074188285adff74d1f1833a6363f891d6eccebdfd825ed",
    "logsBloom": "0x7cfedbef2b4b7b33de4b8ed5c1f9ffeddcff36f1eefbd3770c9dfc76bbb1d37f8fd3fba37a2937fc35cffb9d3719ff4dbf9ff8e11f01dc3d0fd75fff557ffe954d7f5bdea9749f09f8ce07ab6fca33e3affb779faf76bff716851e2fbddfbfbfd303eaec1efdf7aed69bdcaf2a7cfd9a4f46bcd072dc3f6aabc2ddf93ad9dedec7d31db7ef2cbb7edee5b25ceffaedff569aaadd7fc65c1bab75abfa67726eb7b3f9efeb3bf6fefcaffed39f37189e7afff782cdff467fdea7955fee9aa7cbfbb5bce6aef73989db7bbefd31592ff9ff5a63fa6afebf2e7deaddb5fb63dbfbad86b87a7f9f26aae439fcb178b7d607efc7c71bfc7b75e9d7f5ce9bf67dbef447",
    "miner": "0x1ad91ee08f21be3de0ba2ba6918e714da6b45836",
    "mixHash": "0x8b936572649397d24923f64b94b1865ae57901cdfaf2ce8fe75d59913326632a",
    "nonce": "0x2a59d15c02876925",
    "number": "0xc96a6d",
    "parentHash": "0xecab8888f9fc828d9ae07775de4db8b5104fc120349159835bd5d252dcda1834",

I display this info on Otterscan block page.

@wmitsuda wmitsuda added the investigate Under investigation and may be a bug. label Sep 11, 2021
@ricmoo
Copy link
Member

ricmoo commented Sep 11, 2021

The difficulty likely reached the limit of ieee754 numbers, in which case ethers uses null rather than crashing. :)

There isn’t really a backwards compatible way to resolve this in v5. It will be addressed in v6.

Is this a field you need? In a minor bump, I could add a new field which will store the difficulty as a BigNumber, like block._difficulty.

@wmitsuda
Copy link
Author

Yep, I think it is better than crashing :)

Well, my app is a block explorer, so for the sake of completeness I need it. But I agree that it is not something must-have.

I would code a workaround anyway, block._difficulty is fine, if you have a not-so-intrusive workaround from caller side it would be helpful too.

@ricmoo
Copy link
Member

ricmoo commented Sep 11, 2021

As an immediate solution until the next minor-bump, you could use one of the JSON-RPC backed providers (like Alchemy or INFURA) and use the raw .send(method, paeans).

A minor bump is likely a week or two away.

wmitsuda added a commit to otterscan/otterscan that referenced this issue Sep 11, 2021
@ricmoo
Copy link
Member

ricmoo commented Sep 12, 2021

Also see #2001.

@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 Sep 13, 2021
@ricmoo
Copy link
Member

ricmoo commented Oct 20, 2021

The _difficulty property has been added to 5.5.0 for those that needs this.

In v6, the difficulty property is a BigNumber, so the _difficulty property will go away, but for v5 compatibility, difficulty is preserved as a null | number.

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. minor-bump Planned for the next minor version bump.
Projects
None yet
Development

No branches or pull requests

2 participants