Skip to content

make max estimation fee tolerance configurable in call handlers #1591

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

Open
segfault-magnet opened this issue Jan 30, 2025 · 0 comments · May be fixed by #1667
Open

make max estimation fee tolerance configurable in call handlers #1591

segfault-magnet opened this issue Jan 30, 2025 · 0 comments · May be fixed by #1667
Labels
good first issue Good for newcomers

Comments

@segfault-magnet
Copy link
Contributor

segfault-magnet commented Jan 30, 2025

The transaction builders (ScriptTransactionBuilder, BlobTransactionBuilder, CreateTransactionBuilder, etc.) include a max_fee_estimation_tolerance field. This field determines the buffer added to the estimated gas cost when calculating the max_fee for a transaction, if a specific max_fee is not already set via TxPolicies. The default value for this tolerance is currently DEFAULT_MAX_FEE_ESTIMATION_TOLERANCE (0.50), defined in packages/fuels-programs/src/lib.rs.

However, high-level APIs that internally use these builders do not provide a direct way to configure this tolerance before building the transaction:

  1. Executable::upload_blob: This method creates a BlobTransactionBuilder internally and uses the default tolerance without allowing user configuration.

    // packages/fuels-programs/src/executable.rs L180
    let mut tb = BlobTransactionBuilder::default()
        .with_blob(self.blob())
        .with_max_fee_estimation_tolerance(DEFAULT_MAX_FEE_ESTIMATION_TOLERANCE); // Default used
  2. Call Handlers (ScriptCallHandler, ContractCallHandler, etc.): These handlers typically build ScriptTransaction or ContractCall transactions internally. While users can set TxPolicies (potentially including a fixed max_fee), they cannot directly configure the max_fee_estimation_tolerance that the underlying builder will use if fee estimation is performed (i.e., if TxPolicies::max_fee is None).

The current workaround involves obtaining a transaction builder from the configured call handler (e.g., using call_handler.into_builder() or ScriptTransactionBuilder::from(call_handler)) or creating the BlobTransactionBuilder manually. Then, the user must set the desired tolerance on this builder instance using .with_max_fee_estimation_tolerance(new_tolerance), and finally proceed to finalize and send the transaction using the builder directly. This bypasses the convenience of the higher-level methods like .call() or Executable::upload_blob.

This lack of direct configuration forces users to drop to lower-level builder manipulation when they encounter situations where the default tolerance (50%) is insufficient, leading to "InvalidMaxFee" transaction failures.

Requested Change:

Introduce convenient methods on the relevant high-level APIs to allow configuration of the max_fee_estimation_tolerance used by the underlying transaction builders:

@netrome netrome added the good first issue Good for newcomers label Apr 10, 2025 — with Linear
@netrome netrome removed the good first issue Good for newcomers label Apr 10, 2025
@netrome netrome added good first issue Good for newcomers refine labels Apr 10, 2025 — with Linear
@hal3e hal3e closed this as completed May 12, 2025
@hal3e hal3e reopened this May 12, 2025
grandima added a commit to grandima/fuels-rs that referenced this issue May 15, 2025
grandima added a commit to grandima/fuels-rs that referenced this issue May 16, 2025
grandima added a commit to grandima/fuels-rs that referenced this issue May 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants