Skip to content

Conversation

virajbhartiya
Copy link
Member

This PR partially addresses issue #13043 by updating several Ethereum API methods to return pointers instead of values, enabling proper nil handling when blocks or transactions are not found. This change aligns with go-ethereum patterns and improves error handling for not found scenarios. Methods updated: EthGetBalance, EthGetBlockByHash, EthGetBlockByNumber, EthGetBlockTransactionCountByHash, EthGetBlockTransactionCountByNumber, EthGetTransactionCount, and EthFeeHistory. Note: This is a partial implementation - additional methods will be addressed in follow-up PRs.

@github-project-automation github-project-automation bot moved this to 📌 Triage in FilOz May 30, 2025
@virajbhartiya
Copy link
Member Author

Hey @rvagg
I've implemented:

  • EthGetBlockTransactionCountByNumber/Hash*ethtypes.EthUint64
  • EthGetBlockByHash/Number*ethtypes.EthBlock
  • EthGetTransactionCount*ethtypes.EthUint64
  • EthGetBalance*ethtypes.EthBigInt
  • EthFeeHistory*ethtypes.EthFeeHistory

Just wanted to check if this is heading in the right direction before I continue with EthEstimateGas and the "ignore not found errors" logic. Does the approach look good to you?

@virajbhartiya virajbhartiya requested a review from rvagg May 30, 2025 05:29
@rjan90 rjan90 moved this from 📌 Triage to 🔎 Awaiting Review in FilOz May 30, 2025
@rjan90 rjan90 requested a review from masih June 3, 2025 11:49
@masih
Copy link
Member

masih commented Jun 3, 2025

@virajbhartiya Please review the failing CI workflows. Looks like we are missing a make gen.

@virajbhartiya
Copy link
Member Author

Hey @masih , I've fixed the make gen issue, but I am not sure if CI is failing because of the changes made in this PR

@masih
Copy link
Member

masih commented Jun 5, 2025

I am not sure if CI is failing because of the changes made in this PR

At the very least, some CI workflows are failing because of the changes made in this PR. I would:

  • start by looking at lint issues.
  • then move on to looking at eth test failures. This one is a good one to start with.

Make sure tests pass locally before investigating any further false negative CI workflow failures.

@BigLep
Copy link
Member

BigLep commented Jun 10, 2025

@virajbhartiya : there were some itest fixes that checked into master. Can you update your fork to pull those in? I tried rerunning the failed jobs, but I'm still seeing a couple that I believe have been fixed.

@BigLep BigLep moved this from 🔎 Awaiting Review to ⌨️ In Progress in FilOz Jun 23, 2025
@BigLep
Copy link
Member

BigLep commented Jun 23, 2025

@virajbhartiya : it looks like there are a couple of tests consistently failing even after you updated from filecoin-project:master: https://github.com/filecoin-project/lotus/actions/runs/15552300377/job/44641706836?pr=13150

Are you able to look into this?

@rvagg
Copy link
Member

rvagg commented Jun 25, 2025

Sorry for the delay in getting to look at this. It's looking fairly good @virajbhartiya. I think the next steps before landing this would be:

  • Look at that one failing CI test above and see if it's related; I think it might be: go test ./itests/eth_api_f3_test.go to reproduce it locally and verify
  • Rebase on master (or merge master into this)
  • Let's figure out how to get some testing in. There's API tests in eth_api_test.go that we should be able to logically squeeze this into, we just need to have good call patterns that trigger these nil values. I haven't looked in detail but please let me know if you find it a challenge to get some tests in and I'll jump in and figure something out.
  • Reviewer (likely me) just needs to cross-reference and double-check that we're doing the go-ethereum compatible thing on all of these API methods 🤞 .

@BigLep
Copy link
Member

BigLep commented Jul 1, 2025

Hi @virajbhartiya. I know this has been open for a bit and maintainers were delayed in responding. Did you see #13150 (comment) ?

@virajbhartiya
Copy link
Member Author

Hey @BigLep @rvagg , I have made a few changes to test and they pass when I run go test ./itests/eth_api_f3_test.go but failing with gotestsum. How can I fix this?

@BigLep
Copy link
Member

BigLep commented Jul 7, 2025

Hey @BigLep @rvagg , I have made a few changes to test and they pass when I run go test ./itests/eth_api_f3_test.go but failing with gotestsum. How can I fix this?

@virajbhartiya : I looked into this and couldn't figure it out (but also no surprise since I'm no expert here). I think we'll need @rvagg eyes.

@rvagg
Copy link
Member

rvagg commented Jul 9, 2025

@virajbhartiya the failing test is fevm_test, run go test ./itests/fevm_test.go and 🤞 you should see the same failure.

…l rounds in EthFeeHistory and EthEstimateGas
@virajbhartiya
Copy link
Member Author

@rvagg tests are passing now

@BigLep BigLep requested review from rvagg and eddieperez88 July 22, 2025 02:33
@BigLep BigLep moved this from ⌨️ In Progress to 🔎 Awaiting Review in FilOz Jul 22, 2025
@rvagg
Copy link
Member

rvagg commented Jul 24, 2025

In the original issue I suggested you'd need to do a bit of digging in go-ethereum to confirm which should and shouldn't be able to return null. So I did a bit of my own validation of what go-ethereum does based on my original list and the changes made here and this is what I've found:

  1. eth_getBalance internal/ethapi/api.go#L325-L332 - returns nil, nil when block doesn't exist (correct)
  2. eth_getBlockByHash internal/ethapi/api.go#L513-L519 - can return nil, nil when block not found (correct)
  3. eth_getBlockByNumber internal/ethapi/api.go#L496-L509 - can return nil, nil when block not found (correct)
  4. eth_getTransactionCount internal/ethapi/api.go#L1315-L1331 - can return nil, nil when block not found (correct)
  5. eth_getBlockTransactionCountByNumber/Hash Test data showing expected null behavior, both return null for non-existent blocks (correct): eth_getBlockReceipts-hash-notfound.json, eth_getTransactionReceipt-txhash-notfound.json
  6. eth_estimateGas internal/ethapi/api.go#L860-L866 - returns hexutil.Uint64 (NOT a pointer, INCORRECT)
  7. eth_feeHistory internal/ethapi/api.go#L99-L133 - always constructs a result struct when no error (INCORRECT)

So @virajbhartiya would you mind backing out the eth_estimateGas and eth_feeHistory changes from here please?

Sorry for taking so long.

…le nil cases in gateway/proxy_eth_v1.go and gateway/proxy_v2.go. Update tests in itests/eth_api_f3_test.go and itests/eth_fee_history_test.go to reflect changes in return types. Adjust gas.go to return pointers for EthFeeHistory and EthEstimateGas results.
… improved accuracy in gas limit overestimation checks.
@BigLep BigLep moved this from 🔎 Awaiting Review to ⌨️ In Progress in FilOz Aug 12, 2025
@BigLep BigLep requested review from Copilot and removed request for masih and eddieperez88 August 12, 2025 03:30
@BigLep
Copy link
Member

BigLep commented Aug 12, 2025

@virajbhartiya : please re-request review when you're ready for this to be checked over. Thanks!

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates several Ethereum API methods to return pointers instead of values, enabling proper nil handling when blocks or transactions are not found. The changes align with go-ethereum patterns where "not found" scenarios return (nil, nil) rather than zero values with errors. Key changes include updating method signatures, error handling patterns, and comprehensive test updates.

  • Updated method signatures to return pointers for better nil handling
  • Implemented go-ethereum compatible error handling patterns
  • Enhanced fallback error handling in tipset resolver
  • Updated all tests to handle pointer return types

Reviewed Changes

Copilot reviewed 37 out of 37 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
node/impl/eth/transaction.go Core methods updated to return pointers with proper nil handling for not-found scenarios
node/impl/eth/gas.go Gas estimation and fee history methods updated with pointer returns and fallback error handling
node/impl/eth/lookup.go Balance lookup method updated to return pointer with proper error handling
node/impl/eth/tipsetresolver.go Enhanced error handling with fallback to EC safe/finalized tipsets
node/impl/eth/api.go Interface definitions updated to match new pointer return types
gateway/proxy_*.go Proxy methods updated to handle both pointer and value returns
itests/*.go All integration tests updated to dereference pointer returns
api/v2api/*.go Generated API stubs and mocks updated for new signatures
build/openrpc/*.json OpenRPC specifications updated to reflect pointer return types

@BigLep
Copy link
Member

BigLep commented Aug 19, 2025

Also @virajbhartiya : please review the @copilot review as well and then re-request review when ready.

@virajbhartiya
Copy link
Member Author

@BigLep Yes I'll work on those

@virajbhartiya
Copy link
Member Author

@rvagg TestFEVMEamCreateTwiceFail is passing locally by failing the CI

@BigLep BigLep moved this from ⌨️ In Progress to 🔎 Awaiting Review in FilOz Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🔎 Awaiting Review
Development

Successfully merging this pull request may close these issues.

5 participants