Skip to content

Skip gas estimation on sign tx - #802

Open
shayzluf wants to merge 6 commits into
developfrom
skip_gas_estimation_on_sign
Open

Skip gas estimation on sign tx#802
shayzluf wants to merge 6 commits into
developfrom
skip_gas_estimation_on_sign

Conversation

@shayzluf

@shayzluf shayzluf commented Apr 12, 2025

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Introduced an optional parameter for transaction processing that allows users to skip gas estimation, providing more flexibility in transaction configuration.
    • Standard transaction processing remains unchanged by default, ensuring consistent behavior for all users.
  • Chores

    • Added .env to the .gitignore file to prevent it from being tracked by Git.
  • Bug Fixes

    • Removed the export of LOGROCKET_APP_ID, streamlining application configuration by eliminating unused constants.

@coderabbitai

coderabbitai Bot commented Apr 12, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This pull request modifies the getExecutePayoutSafeTransaction function in payouts.utils.ts by introducing a new optional parameter skipGasEstimation, which defaults to false. The function now conditionally assigns an options object based on the skipGasEstimation flag. When skipGasEstimation is true, the options object is set with a safeTxGas value of "200000"; otherwise, it remains undefined. This update affects the transaction creation logic by allowing different configurations depending on the flag. Additionally, the .gitignore file is updated to include .env, preventing these files from being tracked by Git. The LOGROCKET_APP_ID constant is removed from settings.ts, indicating it will no longer be used in the application.

Changes

File Change Summary
packages/.../payouts.utils.ts Added optional skipGasEstimation parameter (default false) to getExecutePayoutSafeTransaction and conditionally set the transaction options with safeTxGas: "200000" when skipGasEstimation is true.
packages/web/.gitignore Added entry to ignore .env files in the Git repository.
packages/web/src/settings.ts Removed LOGROCKET_APP_ID constant which retrieved the REACT_APP_LOGROCKET_APP_ID environment variable.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant PayoutUtil

    Caller->>PayoutUtil: getExecutePayoutSafeTransaction(..., skipGasEstimation)
    alt skipGasEstimation = true
        PayoutUtil->>PayoutUtil: Set options = { safeTxGas: "200000" }
    else skipGasEstimation = false
        PayoutUtil->>PayoutUtil: Set options = undefined
    end
    PayoutUtil->>Caller: Return transaction object
Loading

Poem

I'm a little rabbit, code at play,
Hopping through changes in a brisk new way.
A parameter added to light our code's day,
With "skipGasEstimation" true, gas is set to sway.
In bytes and hops, our work leads the way! 🐇💻
Celebrate the update — hip hip, hooray!

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 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 f249f74 and 76d56d3.

📒 Files selected for processing (1)
  • packages/web/src/settings.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • packages/web/src/settings.ts
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Cloudflare Pages

🪧 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 plan to trigger planning for file edits and PR creation.
  • @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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 (3)
packages/shared/src/utils/payouts.utils.ts (3)

60-61: Consider a more descriptive parameter name and add documentation.

The parameter name signOnly is somewhat clear but could be more descriptive. Consider renaming it to skipGasEstimation to better reflect its purpose. Additionally, adding a JSDoc comment would help explain the parameter's purpose and usage.

 export const getExecutePayoutSafeTransaction = async (
   providerUrl: string,
   committee: string,
-  payout: IPayoutResponse,
-  signOnly: boolean = false
+  payout: IPayoutResponse,
+  skipGasEstimation: boolean = false
 ): Promise<{ tx: SafeTransaction; txHash: string }> => {

With documentation:

+/**
+ * Creates a Safe transaction to execute a payout
+ * @param providerUrl The URL of the provider
+ * @param committee The address of the committee Safe
+ * @param payout The payout response object
+ * @param skipGasEstimation If true, uses a fixed gas value instead of estimating gas
+ * @returns The Safe transaction and transaction hash
+ */
 export const getExecutePayoutSafeTransaction = async (
   providerUrl: string,
   committee: string,
   payout: IPayoutResponse,
-  signOnly: boolean = false
+  skipGasEstimation: boolean = false
 ): Promise<{ tx: SafeTransaction; txHash: string }> => {

115-115: Extract magic number to a named constant.

The fixed gas value "200000" is a magic number that should be extracted to a named constant at the top of the file for better maintainability and documentation.

+// Safe gas estimation default value when skipping gas estimation
+const DEFAULT_SAFE_TX_GAS = "200000";

 export const getExecutePayoutSafeTransaction = async (
   providerUrl: string,
   committee: string,
   payout: IPayoutResponse,
-  signOnly: boolean = false
+  skipGasEstimation: boolean = false
 ): Promise<{ tx: SafeTransaction; txHash: string }> => {
   // ...

   const safeTransaction = await protocolKit.createTransaction({
     transactions: [
       {
         to: contractAddress,
         data: encodedExecPayoutData,
         value: "0",
       },
     ],
-    options: signOnly ? { safeTxGas: "200000" } : undefined,
+    options: skipGasEstimation ? { safeTxGas: DEFAULT_SAFE_TX_GAS } : undefined,
   });

254-254: Replace duplicate magic number with the same constant.

For consistency, use the same named constant here as well.

   const safeTransaction = await protocolKit.createTransaction({
     transactions: [
       {
         to: paymentSplitterFactoryAddress,
         data: encodedPaymentSplitterCreation,
         value: "0",
       },
       {
         to: vaultContract.address,
         data: encodedExecutePayout,
         value: "0",
       },
     ],
-    options: signOnly ? { safeTxGas: "200000" } : undefined,
+    options: skipGasEstimation ? { safeTxGas: DEFAULT_SAFE_TX_GAS } : undefined,
   });
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 003c92b and 35d86f5.

📒 Files selected for processing (1)
  • packages/shared/src/utils/payouts.utils.ts (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/shared/src/utils/payouts.utils.ts (1)
packages/shared/src/types/payout.ts (1)
  • IPayoutResponse (28-43)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (1)
packages/shared/src/utils/payouts.utils.ts (1)

57-62:

Details

❓ Verification inconclusive

Verify impact of providing fixed gas value.

Providing a fixed gas value might lead to failed transactions if the actual gas required exceeds this value. Consider if this is an acceptable trade-off for your use case, especially for more complex transactions like split payouts that might require more gas.


🏁 Script executed:

#!/bin/bash
# Look for other occurrences of safeTxGas in the codebase to understand common usage patterns
rg "safeTxGas" --type ts

Length of output: 520


Evaluate the fixed gas value for signOnly transactions

The function currently uses a hardcoded safeTxGas value of "200000" when signOnly is true. A search in the codebase confirms that this fixed value is consistently used (see occurrences in packages/shared/src/utils/payouts.utils.ts and the type definition in packages/shared/src/types/safe.ts). However, this fixed gas value might not cover complex scenarios—such as split payouts—where the actual gas requirement could exceed 200,000, leading to potential transaction failures.

  • Action Items:
    • Confirm that the fixed safeTxGas value is sufficient for all intended transaction types.
    • Consider implementing a dynamic gas estimation or a fallback mechanism if future transactions are expected to be more complex.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Apr 12, 2025

Copy link
Copy Markdown

Deploying dapp with  Cloudflare Pages  Cloudflare Pages

Latest commit: 76d56d3
Status: ✅  Deploy successful!
Preview URL: https://f1f6369a.dapp-a9y.pages.dev
Branch Preview URL: https://skip-gas-estimation-on-sign.dapp-a9y.pages.dev

View logs

Comment thread packages/shared/src/utils/payouts.utils.ts Outdated
Comment thread packages/shared/src/utils/payouts.utils.ts Outdated
Comment thread packages/shared/src/utils/payouts.utils.ts Outdated
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.

1 participant