Skip to content

Fix double-counting resourceFee #1343

Merged
Ryang-21 merged 3 commits intomasterfrom
fix-double-fee-counting
Mar 3, 2026
Merged

Fix double-counting resourceFee #1343
Ryang-21 merged 3 commits intomasterfrom
fix-double-fee-counting

Conversation

@Ryang-21
Copy link
Copy Markdown
Contributor

@Ryang-21 Ryang-21 commented Mar 3, 2026

  • Fixes double counting resourceFee in Transaction.fee due to resourceFee now being handled in TransactionBuilder.build()
  • rpc.assembleTransaction() now checks if the raw transaction has already been simulated and subtracts xdr.SorobanTransactionData.resourceFee() if the resulting Transaction.fee remains greater than 0.

Copilot AI review requested due to automatic review settings March 3, 2026 19:28
@github-project-automation github-project-automation Bot moved this to Backlog (Not Ready) in DevX Mar 3, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates Soroban transaction fee handling in rpc.assembleTransaction() to avoid double-counting resourceFee when re-assembling a transaction that already has Soroban data attached.

Changes:

  • Adjust assembleTransaction() fee calculation to subtract any pre-existing Soroban resourceFee before cloning/building the transaction.
  • Add unit tests covering re-assembly and pre-existing Soroban data fee scenarios.
  • Document the fix in the changelog.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/rpc/transaction.ts Updates fee handling during transaction assembly to prevent resourceFee being counted twice.
test/unit/transaction.test.ts Adds tests to ensure fees remain stable across re-assembly and with pre-existing Soroban data.
CHANGELOG.md Notes the fix and the updated responsibility for applying resourceFee.
Comments suppressed due to low confidence (2)

src/rpc/transaction.ts:94

  • The fee-related comment above TransactionBuilder.cloneFrom is now inaccurate: the code no longer adds minResourceFee to fee here, and instead relies on TransactionBuilder.build() to incorporate resourceFee from the Soroban transaction data. Please update/remove this comment so it reflects the current behavior (classic fee may be adjusted by subtracting any pre-existing resourceFee, then passed through as-is).
    // automatically update the tx fee that will be set on the resulting tx to
    // the sum of 'classic' fee provided from incoming tx.fee and minResourceFee
    // provided by simulation.
    //
    // 'classic' tx fees are measured as the product of tx.fee * 'number of
    // operations', In soroban contract tx, there can only be single operation
    // in the tx, so can make simplification of total classic fees for the
    // soroban transaction will be equal to incoming tx.fee + minResourceFee.

CHANGELOG.md:11

  • Grammar nit in changelog entry: "as its now" should be "as it's now" (and consider rephrasing to "Removed adding resourceFee in assembleTransaction..." for clarity).
* Removed `resourceFee` adding in `assembleTransaction` as its now handled by `TransactionBuilder.build()`.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 3, 2026

Size Change: +16.1 kB (+0.04%)

Total Size: 45.1 MB

Filename Size Change
dist/stellar-sdk-minimal.js 5.96 MB +2.71 kB (+0.05%)
dist/stellar-sdk-minimal.min.js 5.07 MB +1.31 kB (+0.03%)
dist/stellar-sdk-no-axios.js 5.96 MB +2.71 kB (+0.05%)
dist/stellar-sdk-no-axios.min.js 5.07 MB +1.31 kB (+0.03%)
dist/stellar-sdk-no-eventsource.js 6.21 MB +2.71 kB (+0.04%)
dist/stellar-sdk-no-eventsource.min.js 5.28 MB +1.31 kB (+0.02%)
dist/stellar-sdk.js 6.21 MB +2.71 kB (+0.04%)
dist/stellar-sdk.min.js 5.28 MB +1.31 kB (+0.02%)

compressed-size-action

@Ryang-21 Ryang-21 requested a review from quietbits March 3, 2026 20:00
@Ryang-21 Ryang-21 merged commit ff1d2d4 into master Mar 3, 2026
10 checks passed
@Ryang-21 Ryang-21 deleted the fix-double-fee-counting branch March 3, 2026 20:56
@github-project-automation github-project-automation Bot moved this from Backlog (Not Ready) to Done in DevX Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants