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: Add EthGetBlockReceipts RPC method #4985

Merged
merged 15 commits into from
Nov 25, 2024
Merged

Conversation

virajbhartiya
Copy link
Contributor

@virajbhartiya virajbhartiya commented Nov 13, 2024

Summary of changes

Implemented eth_getBlockReceipts RPC method

Reference issue to close (if applicable)

Closes #4839

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 November 13, 2024 17:46
@virajbhartiya virajbhartiya requested review from ruseinov and elmattic and removed request for a team November 13, 2024 17:46
@CLAassistant
Copy link

CLAassistant commented Nov 13, 2024

CLA assistant check
All committers have signed the CLA.

src/rpc/methods/eth.rs Outdated Show resolved Hide resolved
src/rpc/methods/eth.rs Outdated Show resolved Hide resolved
@elmattic
Copy link
Contributor

Good start!

Also, remember to update the change checklist in the PR and mark the checkboxes (e.g. update the Forest README file to reflect any visible changes for the users).

@virajbhartiya
Copy link
Contributor Author

I have updated the changelog and made the changes according to the reviews.

src/rpc/methods/eth.rs Outdated Show resolved Hide resolved
src/rpc/methods/eth.rs Outdated Show resolved Hide resolved
src/rpc/methods/eth.rs Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@elmattic
Copy link
Contributor

Could you resolve this lint error: https://github.com/ChainSafe/forest/actions/runs/11830899080/job/32966034648?pr=4985 and make the CI ✅ again?

Additionally, please update the README to link to the issue number instead of the PR (See https://github.com/ChainSafe/forest/blob/main/CHANGELOG.md?plain=1#L3-L22)

Thanks!

@virajbhartiya
Copy link
Contributor Author

@elmattic made the changes mentioned above and resolved the lint errors

@elmattic
Copy link
Contributor

Thanks. Hey @virajbhartiya , can you investigate the CI errors? ❌ Feel free to reach me on Slack if you need some help.

@LesnyRumcajs
Copy link
Member

@virajbhartiya It seems Forest is not producing the same output as Lotus (see https://github.com/ChainSafe/forest/actions/runs/11831922981/job/32968391970). I recommend running locally https://github.com/ChainSafe/forest/blob/main/scripts/tests/api_compare/setup.sh and ensuring the logic matches.

image

@virajbhartiya
Copy link
Contributor Author

virajbhartiya commented Nov 22, 2024

While running the API compare command, I came across a few more discrepancies,

RUST_LOG=debug ./target/debug/forest-tool api compare --lotus /ip4/127.0.0.1/tcp/1234/http --forest /ip4/127.0.0.1/tcp/2345/http ../snap.zst --filter EthGetBlockReceipts -n 100

The discrepancies I could find:

Forest response: [
  {
    "blockHash": "0xed55e11735035e3e3a515a652456e0ba695348a7a7355ed987dac1a7dfdfb1d5",
    "blockNumber": "0x20b8ce",
    "contractAddress": null,
    "cumulativeGasUsed": "0x0",
    "effectiveGasPrice": "0x1eb21",
    "from": "0xff00000000000000000000000000000000000f03",
    "gasUsed": "0x579c29",
    "logs": [],
    "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "root": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "status": "0x1",
    "to": "0xff0000000000000000000000ffffffffffffffff",
    "transactionHash": "0xda75f460c1ec86a3dd126cce02be528c8c516516c94a78d51b17aa49f41d6cfa",
    "transactionIndex": "0x0",
    "type": "0x2"
  },
  {
    "blockHash": "0xed55e11735035e3e3a515a652456e0ba695348a7a7355ed987dac1a7dfdfb1d5",
    "blockNumber": "0x20b8ce",
    "contractAddress": null,
    "cumulativeGasUsed": "0x0",
    "effectiveGasPrice": "0x1e681",
    "from": "0xff00000000000000000000000000000000000f03",
    "gasUsed": "0x579c29",
    "logs": [],
    "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "root": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "status": "0x1",
    "to": "0xff0000000000000000000000ffffffffffffffff",
    "transactionHash": "0xe438c6d5f80857a2a2138fe7ec43a0695525b8670a498a201c5b64f71daadc5e",
    "transactionIndex": "0x1",
    "type": "0x2"
  }
]
Lotus response: [
  {
    "blockHash": "0xed55e11735035e3e3a515a652456e0ba695348a7a7355ed987dac1a7dfdfb1d5",
    "blockNumber": "0x20b8ce",
    "contractAddress": null,
    "cumulativeGasUsed": "0x0",
    "effectiveGasPrice": "0x1eb21",
    "from": "0xff00000000000000000000000000000000000f03",
    "gasUsed": "0x579c29",
    "logs": [],
    "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "root": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "status": "0x1",
    "to": "0xff00000000000000000000000000000000023fcc",
    "transactionHash": "0xda75f460c1ec86a3dd126cce02be528c8c516516c94a78d51b17aa49f41d6cfa",
    "transactionIndex": "0x0",
    "type": "0x2"
  },
  {
    "blockHash": "0xed55e11735035e3e3a515a652456e0ba695348a7a7355ed987dac1a7dfdfb1d5",
    "blockNumber": "0x20b8ce",
    "contractAddress": null,
    "cumulativeGasUsed": "0x0",
    "effectiveGasPrice": "0x1e681",
    "from": "0xff00000000000000000000000000000000000f03",
    "gasUsed": "0x579c29",
    "logs": [],
    "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "root": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "status": "0x1",
    "to": "0xff00000000000000000000000000000000023fcd",
    "transactionHash": "0xe438c6d5f80857a2a2138fe7ec43a0695525b8670a498a201c5b64f71daadc5e",
    "transactionIndex": "0x1",
    "type": "0x2"
  }
]
Diff:  [

   {

     "blockHash": "0xed55e11735035e3e3a515a652456e0ba695348a7a7355ed987dac1a7dfdfb1d5",

     "blockNumber": "0x20b8ce",

     "contractAddress": null,

     "cumulativeGasUsed": "0x0",

     "effectiveGasPrice": "0x1eb21",

     "from": "0xff00000000000000000000000000000000000f03",

     "gasUsed": "0x579c29",

     "logs": [],

     "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",

     "root": "0x0000000000000000000000000000000000000000000000000000000000000000",

     "status": "0x1",

-    "to": "0xff0000000000000000000000ffffffffffffffff",

+    "to": "0xff00000000000000000000000000000000023fcc",

     "transactionHash": "0xda75f460c1ec86a3dd126cce02be528c8c516516c94a78d51b17aa49f41d6cfa",

     "transactionIndex": "0x0",

     "type": "0x2"

   },

   {

     "blockHash": "0xed55e11735035e3e3a515a652456e0ba695348a7a7355ed987dac1a7dfdfb1d5",

     "blockNumber": "0x20b8ce",

     "contractAddress": null,

     "cumulativeGasUsed": "0x0",

     "effectiveGasPrice": "0x1e681",

     "from": "0xff00000000000000000000000000000000000f03",

     "gasUsed": "0x579c29",

     "logs": [],

     "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",

     "root": "0x0000000000000000000000000000000000000000000000000000000000000000",

     "status": "0x1",

-    "to": "0xff0000000000000000000000ffffffffffffffff",

+    "to": "0xff00000000000000000000000000000000023fcd",

     "transactionHash": "0xe438c6d5f80857a2a2138fe7ec43a0695525b8670a498a201c5b64f71daadc5e",

     "transactionIndex": "0x1",

     "type": "0x2"

   }

 ]

The block hash and number mismatch is fixed but the to values for some of the responses aren't matching (first returns 0xff0000000000000000000000ffffffffffffffff)

The Final result:

| RPC Method                        | Forest            | Lotus                                                                                                                                                              |
|-----------------------------------|-------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Filecoin.EthGetBlockReceipts      | CustomCheckFailed | Valid                                                                                                                                                              |
| Filecoin.EthGetBlockReceipts (19) | Valid             | Rejected("failed to create Eth receipt: failed to get eth logs for block and transaction: failed to get events for filter from chain indexer: not found in index") |
| Filecoin.EthGetBlockReceipts (80) | Valid             | Valid                                                   

@elmattic
Copy link
Contributor

What version of Lotus are you using?

@elmattic
Copy link
Contributor

elmattic commented Nov 22, 2024

For the Lotus errors "failed to create Eth receipt" I believe we should try the new version of Lotus that features the new indexer and request a backfill:

filecoin-project/lotus#12555 (comment)

@virajbhartiya
Copy link
Contributor Author

I am currently running 1.31.1-dev+calibnet

@elmattic
Copy link
Contributor

I am currently running 1.31.1-dev+calibnet

Nice. Did you try to backfill the indexer db?

https://github.com/filecoin-project/lotus/blob/master/documentation/en/chain-indexer-overview-for-operators.md#upgrade-when-importing-chain-state-from-a-snapshot

Can you see if that removes the "failed to create Eth receipt" errors? Thanks!

@elmattic
Copy link
Contributor

elmattic commented Nov 22, 2024

I will open a PR that fixes the to address mismatch.

Edit: I sent you a message on Slack regarding the fix.

@virajbhartiya
Copy link
Contributor Author

Yes I did backfill the indexer db

@elmattic
Copy link
Contributor

I am currently running 1.31.1-dev+calibnet

Note that on the CI we're still running v1.30.0-rc1 so your mileage may vary.

@elmattic
Copy link
Contributor

elmattic commented Nov 25, 2024

There’s a lint error in the CI ❌ that needs fixing. Can you enable 'Format On Save' in your favorite editor? Thanks!

@virajbhartiya
Copy link
Contributor Author

The CI is ✅ now!

@elmattic elmattic added this pull request to the merge queue Nov 25, 2024
Merged via the queue into ChainSafe:main with commit d7431b7 Nov 25, 2024
33 checks passed
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.

Support eth_getBlockReceipts
6 participants