Skip to content

internal/api: support block number or hash on state-related methods#514

Merged
tungng98 merged 1 commit intoBuildOnViction:pre-releasefrom
c98tristan:feat/eip-1898
Apr 8, 2025
Merged

internal/api: support block number or hash on state-related methods#514
tungng98 merged 1 commit intoBuildOnViction:pre-releasefrom
c98tristan:feat/eip-1898

Conversation

@c98tristan
Copy link
Copy Markdown
Contributor

@c98tristan c98tristan commented Apr 3, 2025

This pull request introduces significant changes to the Viction API backend to support querying by both block number and block hash. The changes include adding new methods to handle BlockNumberOrHash types and updating existing methods to use these new methods.

Methods updated:

  • eth_getBalance
  • eth_getStorageAt
  • eth_getCode
  • eth_getTransactionCount
  • eth_call
  • eth_estimateGas

Support for BlockNumberOrHash:

  • eth/api_backend.go: Added HeaderByNumberOrHash and StateAndHeaderByNumberOrHash methods to handle queries by either block number or block hash. [1] [2]
  • les/api_backend.go: Added HeaderByNumberOrHash and StateAndHeaderByNumberOrHash methods to the LES API backend. [1] [2]

Updates to PublicBlockChainAPI:

Backend Interface Update:

  • internal/ethapi/backend.go: Updated the Backend interface to include the new HeaderByNumberOrHash and StateAndHeaderByNumberOrHash methods.

Test Updates:

  • internal/ethapi/api_test.go: Added new methods to the test backend to support HeaderByNumberOrHash and StateAndHeaderByNumberOrHash. Updated tests to use BlockNumberOrHash. [1] [2] [3]

Miscellaneous:

Referrence:

@tungng98 tungng98 merged commit 76b4384 into BuildOnViction:pre-release Apr 8, 2025
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