Skip to content

Fix Multiple estimations #62

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

Merged
merged 1 commit into from
Mar 20, 2025
Merged

Conversation

vignesha22
Copy link
Contributor

@vignesha22 vignesha22 commented Mar 20, 2025

Description

  • Removed estimation on send userOp when using paymaster
  • Removed estimation on sdk side if paymaster is preset
  • Changed error message on execution reverted

Types of changes

What types of changes does your code introduce?

  • Bugfix (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)
  • Documentation Update
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Other (please describe):

Further comments (optional)

Summary by CodeRabbit

  • Chores

    • Updated the app version to 5.1.1.
  • Bug Fixes

    • Removed redundant fee estimations when a paymaster is active, ensuring more consistent transaction processing.
    • Updated error messages to offer clearer guidance on transaction failures and wallet funding issues.
  • Refactor

    • Streamlined gas fee estimation and transaction verification workflows for smoother and more reliable operations.

Copy link

linear bot commented Mar 20, 2025

Copy link

coderabbitai bot commented Mar 20, 2025

Walkthrough

This update introduces version 5.1.1 to the project. It adds a changelog entry documenting the removal of redundant estimations when a paymaster is set, and bumps the package version. The changes refine fee handling in several API classes by updating gas fee extraction and pre-verification gas logic, add optional fee properties in the paymaster response interface, update error messages for clearer user guidance, and adjust the gas estimation process to conditionally bypass bundler estimation when paymaster details are present.

Changes

File(s) Change Summary
CHANGELOG.md, package.json Added a new changelog section for v5.1.1 and updated the package version from 5.1.0 to 5.1.1.
src/sdk/base/…/BaseAccountAPI.ts, src/sdk/base/…/EtherspotWalletAPI.ts, src/sdk/base/…/VerifyingPaymasterAPI.ts Revised handling of paymaster data. In BaseAccountAPI, added checks for fee parameters and updated preVerificationGas logic; in EtherspotWalletAPI, modified the conversion of the value property; in VerifyingPaymasterAPI, introduced optional fee properties.
src/sdk/errorHandler/…/constants.ts Updated error messages for error codes -32521 and -32500 to provide clearer instructions to users.
src/sdk/…/sdk.ts Restructured the gas estimation logic in the estimate method, wrapping the estimation process within a condition that checks for the absence of paymasterDetails.url, and maintained error handling for call limits.

Sequence Diagram(s)

sequenceDiagram
    participant S as ModularSdk.estimate()
    participant PD as PaymasterDetails
    participant B as Bundler Service

    S->>PD: Check for paymasterDetails.url
    alt URL is defined
        S-->>S: Skip gas estimation
    else URL is not defined
        S->>B: Request gas estimate
        B-->>S: Return gas estimate
        S-->>S: Set maxFee and maxPriorityFee from estimate
    end
Loading

Suggested reviewers

  • kanthgithub
  • nikhilkumar1612
  • ch4r10t33r

Poem

I’m a bunny in the code garden, hopping with delight,
Celebrating changes that make our flow just right.
Fees and gas now dance in a streamlined tune,
Version bump shines like a bright, full moon.
With each little tweak, I nibble a carrot bite,
Cheering our code to new heights! 🥕🐰

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/sdk/base/BaseAccountAPI.ts

Oops! Something went wrong! :(

ESLint: 8.28.0

Error [ERR_REQUIRE_ESM]: require() of ES Module /.eslintrc.js from /node_modules/.pnpm/@eslint[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs not supported.
.eslintrc.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead either rename .eslintrc.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

at TracingChannel.traceSync (node:diagnostics_channel:315:14)
at module.exports [as default] (/node_modules/.pnpm/[email protected]/node_modules/import-fresh/index.js:33:91)
at loadJSConfigFile (/node_modules/.pnpm/@[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2562:47)
at loadConfigFile (/node_modules/.pnpm/@[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2646:20)
at ConfigArrayFactory.loadInDirectory (/node_modules/.pnpm/@[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2856:34)
src/sdk/base/EtherspotWalletAPI.ts

Oops! Something went wrong! :(

ESLint: 8.28.0

Error [ERR_REQUIRE_ESM]: require() of ES Module /.eslintrc.js from /node_modules/.pnpm/@eslint[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs not supported.
.eslintrc.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead either rename .eslintrc.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

at TracingChannel.traceSync (node:diagnostics_channel:315:14)
at module.exports [as default] (/node_modules/.pnpm/[email protected]/node_modules/import-fresh/index.js:33:91)
at loadJSConfigFile (/node_modules/.pnpm/@[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2562:47)
at loadConfigFile (/node_modules/.pnpm/@[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2646:20)
at ConfigArrayFactory.loadInDirectory (/node_modules/.pnpm/@[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2856:34)
src/sdk/base/VerifyingPaymasterAPI.ts

Oops! Something went wrong! :(

ESLint: 8.28.0

Error [ERR_REQUIRE_ESM]: require() of ES Module /.eslintrc.js from /node_modules/.pnpm/@eslint[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs not supported.
.eslintrc.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead either rename .eslintrc.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

at TracingChannel.traceSync (node:diagnostics_channel:315:14)
at module.exports [as default] (/node_modules/.pnpm/[email protected]/node_modules/import-fresh/index.js:33:91)
at loadJSConfigFile (/node_modules/.pnpm/@[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2562:47)
at loadConfigFile (/node_modules/.pnpm/@[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2646:20)
at ConfigArrayFactory.loadInDirectory (/node_modules/.pnpm/@[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2856:34)
  • 2 others

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 58d0c08 and cdf1f2f.

⛔ Files ignored due to path filters (1)
  • bun.lockb is excluded by !**/bun.lockb
📒 Files selected for processing (7)
  • CHANGELOG.md (1 hunks)
  • package.json (1 hunks)
  • src/sdk/base/BaseAccountAPI.ts (1 hunks)
  • src/sdk/base/EtherspotWalletAPI.ts (1 hunks)
  • src/sdk/base/VerifyingPaymasterAPI.ts (1 hunks)
  • src/sdk/errorHandler/constants.ts (1 hunks)
  • src/sdk/sdk.ts (1 hunks)
🔇 Additional comments (9)
package.json (1)

3-3: Version update to 5.1.1 aligns with the bug fix

The version bump properly follows semantic versioning for a non-breaking bug fix.

CHANGELOG.md (1)

2-4: Good documentation of the changes

The changelog entry clearly documents the purpose of this release - removing redundant estimations when a paymaster is set in userOp.

src/sdk/base/EtherspotWalletAPI.ts (1)

400-400: Improved value conversion for better type safety

The change improves how values are converted to bigint in batch operations. Using BigNumber.from().toBigInt() provides a more robust conversion compared to directly using BigInt(), especially when dealing with various numeric types.

src/sdk/base/VerifyingPaymasterAPI.ts (1)

22-23: Adding gas fee properties allows for paymaster-provided fee values

Adding optional maxFeePerGas and maxPriorityFeePerGas properties to the PaymasterResponse interface enables the paymaster to specify gas parameters, eliminating the need for redundant client-side estimation. This directly addresses the PR's objective of removing multiple estimations when a paymaster is used.

You might want to verify that all code paths utilizing the PaymasterResponse properly handle the case when these new fields are present:

#!/bin/bash
# Find all locations where PaymasterResponse is used
rg "PaymasterResponse|paymasterData.result" --type ts 
src/sdk/base/BaseAccountAPI.ts (2)

462-465: Good addition for paymaster fee utilization.

This new condition correctly utilizes the gas fee values provided by the paymaster response, eliminating the need for redundant gas estimations. This aligns with the PR objective to fix multiple estimations when a paymaster is set.


468-468: Improved preVerificationGas handling.

This change ensures that when a paymaster is used, its preVerificationGas value is prioritized over calculating it again, which helps avoid duplicate estimations as intended in the PR objectives.

src/sdk/errorHandler/constants.ts (2)

3-3: Enhanced error message clarity.

The updated error message provides better guidance to users when UserOp execution fails, directing them to contact the wallet provider rather than just suggesting a balance check.


4-4: Improved user guidance for wallet creation errors.

The enhanced error message now provides users with a fallback action (contacting wallet provider) when ensuring sufficient funds doesn't resolve the issue, which improves the troubleshooting process.

src/sdk/sdk.ts (1)

198-221: Successfully eliminated redundant estimations with paymaster.

This conditional block effectively implements the core PR objective - skipping bundler-side gas estimation when a paymaster is present. The estimation process now only runs when no paymaster URL is provided, which prevents the multiple estimation issues.

The original code was estimating gas parameters regardless of whether a paymaster was set, which could lead to inconsistencies and inefficiencies.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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
Member

@ch4r10t33r ch4r10t33r left a comment

Choose a reason for hiding this comment

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

LGTM

@vignesha22 vignesha22 merged commit 90bedb6 into master Mar 20, 2025
5 checks passed
@vignesha22 vignesha22 deleted the PRO-3129-Fix_Multiple_Estimations branch March 20, 2025 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants