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(rpc): implement EthGetTransactionByBlockNumberAndIndex #5030

Conversation

virajbhartiya
Copy link
Contributor

Summary of changes

Changes introduced in this pull request:

implement EthGetTransactionByBlockNumberAndIndex

Reference issue to close (if applicable)

Closes #5020

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation. All new code adheres to the team's documentation standards,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

@virajbhartiya virajbhartiya requested a review from a team as a code owner December 3, 2024 10:08
@virajbhartiya virajbhartiya requested review from ruseinov and hanabi1224 and removed request for a team December 3, 2024 10:08
src/rpc/methods/eth.rs Outdated Show resolved Hide resolved
@elmattic
Copy link
Contributor

elmattic commented Dec 3, 2024

You have some CI error:

| Filecoin.EthGetTransactionByBlockNumberAndIndex (5) | Rejected("index 0 out of range: tipset contains 0 messages")                                  | Rejected("failed to get transaction at index 0: index 0 out of range: tipset contains 0 messages")

The failure is likely due to this identity test using the policy PolicyOnRejected::PassWithIdenticalError and in this case error strings do not match.

@elmattic
Copy link
Contributor

elmattic commented Dec 3, 2024

Lotus method implementation is accepting values like "latest", "pending", etc? (see filecoin-project/lotus#12618 (comment))

What about us?

@LesnyRumcajs LesnyRumcajs removed the request for review from ruseinov December 4, 2024 10:01
@elmattic
Copy link
Contributor

elmattic commented Dec 4, 2024

@virajbhartiya can you put the PR back to draft and only turn it to RFR when CI is ✅? Thanks!

In general, no green checkmark => no review.

@virajbhartiya virajbhartiya marked this pull request as draft December 4, 2024 13:54
@elmattic
Copy link
Contributor

elmattic commented Dec 5, 2024

https://www.quicknode.com/docs/ethereum/eth_getTransactionByBlockNumberAndIndex

According to the specification, the method accepts only a string in hexadecimal format or tags for the block number. We can also support this by using a type like:

enum BlockNumberOrTag {
    BlockNumber(EthInt64),
    PredefinedBlock(Predefined),
}

Then we can create a conversion function to build a BlockNumberOrHash from this type and pass it to the tipset_by_block_number_or_hash function. What do you think?

Of course, we can choose to diverge from the Ethereum specification (and to what is implemented in Lotus), but this would complicate our efforts to align with a common OpenRPC standard.

See filecoin-project/FIPs#1027.

edit: Actually, we already have similar type implemented, it's calledBlockNumberOrPredefined.

CHANGELOG.md Outdated
@@ -80,6 +80,11 @@ methods, fixes (notably to the garbage collection), and other improvements.
- [#4701](https://github.com/ChainSafe/forest/issues/4701) Add support for the
`Filecoin.EthGetTransactionByBlockHashAndIndex` RPC method.

- [#5020](https://github.com/ChainSafe/forest/issues/5020) Add support for the
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this needs to be moved to under Forest unreleased section

@elmattic elmattic marked this pull request as ready for review December 16, 2024 14:33
@elmattic elmattic requested a review from hanabi1224 December 16, 2024 14:35
@lemmih lemmih enabled auto-merge December 16, 2024 14:38
@lemmih lemmih added this pull request to the merge queue Dec 16, 2024
Merged via the queue into ChainSafe:main with commit eb11869 Dec 16, 2024
39 checks passed
@virajbhartiya virajbhartiya deleted the feat/EthGetTransactionByBlockNumberAndIndex branch December 16, 2024 18:52
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.

EthGetTransactionByBlockNumberAndIndex
4 participants