Skip to content

fix: invalid Filecoin.GasEstimateGasPremium & Filecoin.GasEstimateFeeCap response type#7228

Open
LesnyRumcajs wants to merge 5 commits into
mainfrom
fix-gas-estimate-gas-premium-output
Open

fix: invalid Filecoin.GasEstimateGasPremium & Filecoin.GasEstimateFeeCap response type#7228
LesnyRumcajs wants to merge 5 commits into
mainfrom
fix-gas-estimate-gas-premium-output

Conversation

@LesnyRumcajs

@LesnyRumcajs LesnyRumcajs commented Jun 23, 2026

Copy link
Copy Markdown
Member

Summary of changes

Changes introduced in this pull request:

  • fixed invalid RPC signature for Filecoin.GasEstimateGasPremium + test

Reference issue to close (if applicable)

Closes #7227

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.

Outside contributions

  • I have read and agree to the CONTRIBUTING document.
  • I have read and agree to the AI Policy document. I understand that failure to comply with the guidelines will lead to rejection of the pull request.

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Corrected the gas estimation API responses for Filecoin.GasEstimateFeeCap and Filecoin.GasEstimateGasPremium to return whole integer values instead of fractional results.
  • Tests

    • Improved API comparison and validation for gas estimation: negative fee caps/premiums are now rejected, and results are checked for consistency between implementations within a 5% tolerance.
    • Updated the API comparison filter list to mark Filecoin.GasEstimateFeeCap as not supported by the Lotus gateway.

@LesnyRumcajs LesnyRumcajs requested a review from a team as a code owner June 23, 2026 08:30
@LesnyRumcajs LesnyRumcajs added the RPC requires calibnet RPC checks to run on CI label Jun 23, 2026
@LesnyRumcajs LesnyRumcajs requested review from hanabi1224 and sudo-shashank and removed request for a team June 23, 2026 08:30
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 53d5e4c6-10ca-414a-ba74-66f04d8ae5f6

📥 Commits

Reviewing files that changed from the base of the PR and between 9163515 and 7a12281.

📒 Files selected for processing (1)
  • src/tool/subcommands/api_cmd/api_compare_tests.rs
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • filecoin-project/lotus (manual)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/tool/subcommands/api_cmd/api_compare_tests.rs

Walkthrough

Two RPC methods, GasEstimateFeeCap and GasEstimateGasPremium, change their response type from String to TokenAmount, removing the .to_string() conversion in their handlers. API comparison tests are extended with non-negativity checks and a ±5% Forest-vs-Lotus bound for both methods. A changelog entry documents the fix, and a test filter is updated to mark GasEstimateFeeCap as unsupported by lotus-gateway.

Changes

Gas Estimate Return Type Fix

Layer / File(s) Summary
Return type and handler changes
src/rpc/methods/gas.rs, CHANGELOG.md
type Ok is changed from String to TokenAmount for both GasEstimateFeeCap and GasEstimateGasPremium, and the .to_string() conversion is removed from each handle implementation so the computed TokenAmount is returned directly. Changelog entry added under Fixed.
API comparison test validation
src/tool/subcommands/api_cmd/api_compare_tests.rs, scripts/tests/api_compare/filter-list-gateway
message.clone() is used for GasEstimateMessageGas to keep message available. Two new RpcTest::validate cases are added: one for GasEstimateGasPremium and one for GasEstimateFeeCap, each asserting non-negative results and that Forest's value is within 5% of Lotus. Gateway filter is updated to mark GasEstimateFeeCap as unsupported.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • akaladarshi
  • hanabi1224
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing response types for two RPC methods from String to TokenAmount/BigInt.
Linked Issues check ✅ Passed All three completion criteria from #7227 are met: (1) String→BigInt conversion fixed by changing response type to TokenAmount, (2) test coverage added via validators in api_compare_tests.rs, (3) audit conducted.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the RPC response types and corresponding test coverage. No out-of-scope modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-gas-estimate-gas-premium-output
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix-gas-estimate-gas-premium-output

Comment @coderabbitai help to get the list of available commands.

@LesnyRumcajs LesnyRumcajs force-pushed the fix-gas-estimate-gas-premium-output branch from 75a0a93 to 7bb961c Compare June 23, 2026 08:31
hanabi1224
hanabi1224 previously approved these changes Jun 23, 2026
sudo-shashank
sudo-shashank previously approved these changes Jun 23, 2026
@LesnyRumcajs LesnyRumcajs dismissed stale reviews from sudo-shashank and hanabi1224 via 45046ee June 23, 2026 08:41
@LesnyRumcajs LesnyRumcajs changed the title fix: invalid Filecoin.GasEstimateGasPremium response type fix: invalid Filecoin.GasEstimateGasPremium & Filecoin.GasEstimateFeeCap response type Jun 23, 2026
@LesnyRumcajs LesnyRumcajs force-pushed the fix-gas-estimate-gas-premium-output branch from 45046ee to 9768e50 Compare June 23, 2026 08:41
@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.01%. Comparing base (08d39a2) to head (7a12281).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/rpc/methods/gas.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
src/rpc/methods/gas.rs 86.59% <0.00%> (+0.48%) ⬆️

... and 4 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 08d39a2...7a12281. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

sudo-shashank
sudo-shashank previously approved these changes Jun 23, 2026
@LesnyRumcajs

Copy link
Copy Markdown
Member Author

There might be even more problems with those methods...

@LesnyRumcajs LesnyRumcajs marked this pull request as ready for review June 23, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RPC requires calibnet RPC checks to run on CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filecoin.GasEstimateGasPremium invalid output

3 participants