ChainSafe / forest

🌲 Rust Filecoin Node Implementation
https://forest.chainsafe.io
Apache License 2.0
638 stars 160 forks source link

feat: Add EthGetBlockReceipts RPC method #4985

Closed virajbhartiya closed 8 hours ago

virajbhartiya commented 1 week ago

Summary of changes

Implemented eth_getBlockReceipts RPC method

Reference issue to close (if applicable)

Closes #4839

Change checklist

CLAassistant commented 1 week ago

CLA assistant check
All committers have signed the CLA.

elmattic commented 1 week ago

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 commented 1 week ago

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

elmattic commented 1 week ago

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 commented 1 week ago

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

elmattic commented 1 week ago

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

LesnyRumcajs commented 1 week ago

@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 commented 3 days ago

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 commented 3 days ago

What version of Lotus are you using?

elmattic commented 3 days ago

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:

https://github.com/filecoin-project/lotus/issues/12555#issuecomment-2487409108

virajbhartiya commented 3 days ago

I am currently running 1.31.1-dev+calibnet

elmattic commented 3 days ago

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 commented 3 days ago

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

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

virajbhartiya commented 3 days ago

Yes I did backfill the indexer db

elmattic commented 18 hours ago

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 commented 14 hours ago

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

virajbhartiya commented 12 hours ago

The CI is ✅ now!