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

Change BlockNumber to BlockTags for existing APIs #228

Merged
merged 2 commits into from
May 25, 2022

Conversation

shemnon
Copy link
Contributor

@shemnon shemnon commented May 24, 2022

Some APIs specified in older JSON-RPC documentation
accepted a block number or a block tag. Some carried
that difference over, some didn't.

This delta adds tags as an option to

  • eth_getBlockByNumber
  • eth_getBlockTransactionCountByNumber
  • eth_getUncleCountByBlockNumber
  • eth_getTransactionByBlockNumberAndIndex

This brings those APIs in line with https://eth.wiki/json-rpc/API,
except for eth_getLogs and eth_newFilter which have only 50% support for block tags among clients

Signed-off-by: Danno Ferrin danno.ferrin@gmail.com

Some APIs specified in older JSON-RPC documentation
accepted a block number or a block tag. Some carried
that difference over, some didn't.

This delta adds tags as an option to
* eth_getBlockByNumber
* eth_getBlockTransactionCountByNumber
* eth_getUncleCountByBlockNumber
* eth_getTransactionByBlockNumberAndIndex
* eth_getLogs
* eth_newFilter

This brings those APIs  in line with https://eth.wiki/json-rpc/API

Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
Copy link
Member

@lightclient lightclient left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @shemnon. It doesn't appear that fromBlock or toBlock accept block tags in geth. Do other clients support this? Since nil denotes it being the latest, I'm inclined to leave those two as-is and merge your other changes.

Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
@shemnon
Copy link
Contributor Author

shemnon commented May 25, 2022

Besu supports the block tag in filters. My querying of code indicates Nethermind does, and erigon does not.

All of the docs sites I can google indicate eth_getLogs and eth_newFilter should support tags. (mostly because they are cut and paste from the same original site).

However, I'm not aware of any tooling that expects it. I discovered HardHat will call eth_getBlockByNumber('latest') which is what prompted this audit.

Rolled back filter args because numbers are compatible with all 4 clients.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants