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

backport fix for: 1826 #1837

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

backport fix for: 1826 #1837

wants to merge 1 commit into from

Conversation

claytonneal
Copy link
Member

@claytonneal claytonneal commented Feb 19, 2025

Description

Backport to main of fix for #1826 thats been fixed on 1.0.0 release branch

Fixes #1826

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • [] New feature (non-breaking change which adds functionality)
  • [] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [] This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • unit tests

Test Configuration:

  • Node.js Version: 18.18.0
  • Yarn Version:

Checklist:

  • My code follows the coding standards of this project
  • I have performed a self-review of my code
  • I have commented on my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • New and existing integration tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have not added any vulnerable dependencies to my code

Summary by CodeRabbit

  • Tests
    • Enhanced test scripts to enforce consistent code coverage thresholds using updated environment settings.
  • Refactor
    • Streamlined the transaction gas estimation process for more consistent output when handling empty data.
  • Chores
    • Adjusted the build configuration to disable caching, ensuring a more predictable and reliable build process.

@claytonneal claytonneal requested a review from a team as a code owner February 20, 2025 00:00
Copy link
Contributor

coderabbitai bot commented Feb 20, 2025

Walkthrough

This pull request updates the testing and build configurations, as well as refines functionality in the eth_estimateGas method and its related tests. The Jest configuration now uses a new environment variable (APPLYCODECOVLIMITS) to apply coverage thresholds. Testing scripts in the package manifest have been updated accordingly. Additionally, the eth_estimateGas function has been refactored to adjust default values and streamline its return statement, with corresponding changes made to its test fixtures. The turbo configuration has been modified to disable caching for the build task.

Changes

File(s) Change Summary
packages/network/jest.config.js
packages/network/package.json
Updated environment variable logic: Replaced isUnitTest with applyCodeCoverageLimits in Jest config and modified test scripts to set APPLYCODECOVLIMITS (false for unit/integration tests; true for combined tests).
packages/network/src/provider/utils/rpc-mapper/methods/eth_estimateGas/eth_estimateGas.ts Modified ethEstimateGas function: changed default data value from '0x0' to '0x' and simplified return value by removing the Promise wrapper.
packages/network/tests/provider/rpc-mapper/methods/eth_estimateGas/fixture.ts Adjusted test fixtures for ethEstimateGas: removed certain imports, restructured positive case input objects, and removed a negative test case checking for missing parameters.
turbo.json Disabled caching for the "build" task by adding "cache": false.

Sequence Diagram(s)

sequenceDiagram
    participant Script as Test Script
    participant JestConf as Jest Config
    Script->>JestConf: Run tests with APPLYCODECOVLIMITS env var
    JestConf->>JestConf: Evaluate APPLYCODECOVLIMITS value
    alt Value is 'true'
        JestConf-->>Script: Apply coverage thresholds
    else Value is not 'true'
        JestConf-->>Script: Skip coverage thresholds
    end
Loading
sequenceDiagram
    participant Client as Caller
    participant EthGas as ethEstimateGas Function
    Client->>EthGas: Invoke with transaction parameters
    alt Data field is undefined
        EthGas-->>EthGas: Set default data to '0x'
    end
    EthGas-->>Client: Return estimated gas as hex value
Loading

Suggested labels

Size: Medium, Priority: High

Suggested reviewers

  • lucanicoladebiasi
  • fabiorigam

Poem

In code we trust, with changes new,
Coverage checks now come into view.
Tests run smoother, logic tight,
Commit flying like a kite! 🚀
Cheers to progress, in code we write!

Happy coding!

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (4)
packages/network/package.json (4)

35-35: Explicit Unit Test Coverage Configuration
Adding APPLYCODECOVLIMITS=false clearly designates that unit tests should not enforce coverage limits.

Suggestion: Consider using a tool like cross-env for setting environment variables so that this script works seamlessly across different operating systems.


36-36: Explicit Integration Test Coverage Configuration
The integration test command now correctly sets APPLYCODECOVLIMITS=false, making the intended test behavior explicit.

Suggestion: Similar to the unit tests, wrapping the environment variable assignment with cross-env might help maintain cross-platform consistency.


37-37: Integration Solo Test Command Logic Review
The test:integration:solo script includes the environment variable APPLYCODECOVLIMITS=false. The chaining of commands with && followed by an || to run yarn stop-thor-solo ensures that the stopping command executes even if earlier steps fail.

Note: Double-check that this command grouping aligns with your error handling expectations. Consider grouping commands in parentheses if a more explicit order of operations is desired.


39-39: Global Test Command Coverage Enforcement
Updating the main test script with APPLYCODECOVLIMITS=true enforces the coverage limits appropriately when running all tests together.

Suggestion: Using cross-env here as well could improve cross-platform compatibility, ensuring consistent behavior across different development environments.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f7de71b and 12201ff.

📒 Files selected for processing (5)
  • packages/network/jest.config.js (2 hunks)
  • packages/network/package.json (1 hunks)
  • packages/network/src/provider/utils/rpc-mapper/methods/eth_estimateGas/eth_estimateGas.ts (2 hunks)
  • packages/network/tests/provider/rpc-mapper/methods/eth_estimateGas/fixture.ts (3 hunks)
  • turbo.json (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: rpc-proxy / test / test
  • GitHub Check: unit-integration-test-browser / Build & Lint (latest)
  • GitHub Check: unit-integration-test-browser / Build & Lint (lts/*)
  • GitHub Check: unit-integration-test-browser / Build & Lint (18)
  • GitHub Check: unit-integration-test / Build & Lint (latest)
  • GitHub Check: unit-integration-test / Build & Lint (lts/*)
  • GitHub Check: unit-integration-test / Build & Lint (18)
  • GitHub Check: test-apps / Install and test example apps
  • GitHub Check: install-build / Build & Lint
  • GitHub Check: Execute doc examples
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (4)
packages/network/jest.config.js (1)

3-3: LGTM! Clear and explicit coverage threshold control.

The change from UNIT to APPLYCODECOVLIMITS makes the coverage threshold control more explicit and self-documenting.

Also applies to: 13-13

packages/network/src/provider/utils/rpc-mapper/methods/eth_estimateGas/eth_estimateGas.ts (1)

55-55: LGTM! Improved Ethereum compatibility and code clarity.

Two good improvements:

  1. Using '0x' as default data value aligns with Ethereum's empty data representation
  2. Simplified return statement while maintaining Promise functionality

Also applies to: 65-65

packages/network/tests/provider/rpc-mapper/methods/eth_estimateGas/fixture.ts (1)

1-1: LGTM! Enhanced test coverage with clearer test cases.

The changes improve the test suite by:

  1. Simplifying imports to essential dependencies
  2. Using plain objects for test inputs
  3. Adding coverage for optional 'from' parameter

Also applies to: 10-14, 31-41

turbo.json (1)

5-6: Verify if build cache disabling is necessary.

Disabling the build cache could impact build performance. Please confirm if this is necessary for the backport fix.

Could you explain why the build cache needs to be disabled? If it's not strictly required for the backport fix, consider keeping the cache enabled for better build performance.

Copy link

Test Coverage

Summary

Lines Statements Branches Functions
Coverage: 98%
98.96% (4395/4441) 96.94% (1397/1441) 98.9% (906/916)
Title Tests Skipped Failures Errors Time
core 839 0 💤 0 ❌ 0 🔥 2m 35s ⏱️
network 728 0 💤 0 ❌ 0 🔥 5m 13s ⏱️
errors 40 0 💤 0 ❌ 0 🔥 17.928s ⏱️
logging 3 0 💤 0 ❌ 0 🔥 19.214s ⏱️
hardhat-plugin 19 0 💤 0 ❌ 0 🔥 1m 10s ⏱️
aws-kms-adapter 23 0 💤 0 ❌ 0 🔥 1m 26s ⏱️
ethers-adapter 5 0 💤 0 ❌ 0 🔥 1m 21s ⏱️
rpc-proxy 37 0 💤 0 ❌ 0 🔥 1m 27s ⏱️

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.

🐛 [BUG] - eth_estimateGas fails systematically
1 participant