Skip to content

fix: block parsing for account-related etc rpc endpoints#256

Merged
fmoletta merged 6 commits into
mainfrom
fix-rpc-requests-block-parsing
Aug 16, 2024
Merged

fix: block parsing for account-related etc rpc endpoints#256
fmoletta merged 6 commits into
mainfrom
fix-rpc-requests-block-parsing

Conversation

@fmoletta

@fmoletta fmoletta commented Aug 14, 2024

Copy link
Copy Markdown
Contributor

Motivation

Rpc endpoints such as etc_getBalance, eth_getStorageAt, etc can receive either the block number, block hash, or tag as the block field. We are currently using the same BlockIdentifier struct that we use on other rpc endpoints that only accept block number or block tag, leading to failures when parsing hive rpc requests.
This PR aims to fix this issue by introducing a BlockIdentifierOrHash struct which leverages the functionality of BlockIdentifier and adds the hash variant

Description

  • Add struct BlockIdentifierOrHash to parse block values in account-related rpc endpoints
  • Move resolve_block_number to a BlockIdentifier method to avoid name clashes
  • Implement resolve_block_number for BlockIdentifierOrHash

Closes None, but fixes parsing errors on hive tests

@fmoletta fmoletta marked this pull request as ready for review August 14, 2024 19:25
@fmoletta fmoletta requested a review from a team as a code owner August 14, 2024 19:25

@ElFantasma ElFantasma left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it not possible to include the Hash variant within BlockIdentifier instead of creating a new enum?
Or there are cases where BlockHash is not allowed?

@fmoletta

Copy link
Copy Markdown
Contributor Author

Is it not possible to include the Hash variant within BlockIdentifier instead of creating a new enum? Or there are cases where BlockHash is not allowed?

Yes, not all enpoints allow block hash as a valid input

@fmoletta fmoletta added this pull request to the merge queue Aug 16, 2024
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Aug 16, 2024
@fmoletta fmoletta enabled auto-merge August 16, 2024 15:09
@fmoletta fmoletta added this pull request to the merge queue Aug 16, 2024
Merged via the queue into main with commit 4ef7a9d Aug 16, 2024
@fmoletta fmoletta deleted the fix-rpc-requests-block-parsing branch August 16, 2024 15:14
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