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

feat(jsonrpc): ethGetBlockByNumber supports finalized #6007

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

waynercheung
Copy link
Contributor

@waynercheung waynercheung commented Sep 18, 2024

What does this PR do?
make ethGetBlockByNumber supports finalized

Why are these changes required?
For many developers, they need to get the latest solidified/finalized block number, then fetch other data by this number.

For more details, visit issue #5953

This PR has been tested by:

  • Unit Tests
  • Manual Testing

Follow up

Extra details

fromBlockSrc = JsonRpcApiUtil.getByJsonBlockId(fr.getFromBlock());
toBlockSrc = JsonRpcApiUtil.getByJsonBlockId(fr.getToBlock());
fromBlockSrc = JsonRpcApiUtil.getByJsonBlockId(fr.getFromBlock(), wallet);
toBlockSrc = JsonRpcApiUtil.getByJsonBlockId(fr.getToBlock(), wallet);
Copy link

Choose a reason for hiding this comment

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

Show in my waalet

@@ -51,15 +51,15 @@ public LogFilterWrapper(FilterRequest fr, long currentMaxBlockNum, Wallet wallet
// then if toBlock < maxBlockNum, set fromBlock = toBlock
// then if toBlock >= maxBlockNum, set fromBlock = maxBlockNum
if (StringUtils.isEmpty(fr.getFromBlock()) && StringUtils.isNotEmpty(fr.getToBlock())) {
toBlockSrc = JsonRpcApiUtil.getByJsonBlockId(fr.getToBlock());
Copy link
Contributor

Choose a reason for hiding this comment

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

The method public static long getByJsonBlockId(String blockNumOrTag) is only used in LogFilterWrapper, and it should not support finalized. So it should throw new JsonRpcInvalidParamsException("TAG finalized not supported");

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.

eth_getblockbynumber supports finalized except latest, pending and blocknumber
3 participants