Skip to content

Fix tx simulate re-assembly dropping auth and double-counting fees - #2666

Merged
fnando merged 3 commits into
mainfrom
reassemble-auth-and-fee
Aug 4, 2026
Merged

Fix tx simulate re-assembly dropping auth and double-counting fees#2666
fnando merged 3 commits into
mainfrom
reassemble-auth-and-fee

Conversation

@fnando

@fnando fnando commented Aug 4, 2026

Copy link
Copy Markdown
Member

What

Fixes two bugs in assemble() (cmd/soroban-cli/src/assembled.rs) that surface when tx simulate runs on an envelope that is already assembled or partially authorized.

  1. Recorded auth is no longer dropped. The requested auth mode is now threaded into assemble(). When an explicit record mode (--auth-mode=root / non-root) is used, the simulation-recorded authorization entries replace the entries already on the transaction. For enforce / unset, the previous behavior is kept: auth is only filled in when the operation has none, so caller-provided entries are preserved.

  2. The resource fee is no longer double-counted. If the incoming transaction already carries SorobanTransactionData (ext V1) whose resource_fee is folded into raw.fee, that amount is now subtracted from the inclusion fee before adding the simulated resource fee (only when raw.fee > resource_fee), mirroring the JS SDK's assembleTransaction guard.

Why

Re-simulating an already-assembled/partially-authorized envelope — e.g. re-recording a partially authorized transaction to capture non-root sub-invocation auth — previously silently discarded freshly recorded auth and inflated the fee. Fixes #2603.

Known limitations

When a record mode is requested but the simulation returns empty recorded auth, existing entries are fully replaced (cleared) to match what was recorded — the "full replace" reading of the issue.

Copilot AI balanced review requested due to automatic review settings August 4, 2026 11:40
@github-project-automation github-project-automation Bot moved this to Backlog (Not Ready) in DevX Aug 4, 2026
@fnando
fnando force-pushed the reassemble-auth-and-fee branch from f8ef108 to 15cb765 Compare August 4, 2026 11:40
@fnando fnando self-assigned this Aug 4, 2026
@fnando fnando moved this from Backlog (Not Ready) to Needs Review in DevX Aug 4, 2026

Copilot AI 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.

Pull request overview

Fixes tx simulate reassembly to preserve recorded authorization correctly and avoid resource-fee inflation.

Changes:

  • Replaces existing auth when explicit recording mode is requested.
  • Subtracts an existing resource fee before applying the simulated fee.
  • Adds focused unit tests for auth and fee behavior.

Comment thread cmd/soroban-cli/src/assembled.rs
@fnando
fnando requested a review from mootz12 August 4, 2026 12:00
@fnando
fnando enabled auto-merge (squash) August 4, 2026 20:43
@fnando
fnando merged commit e4896a1 into main Aug 4, 2026
225 of 226 checks passed
@fnando
fnando deleted the reassemble-auth-and-fee branch August 4, 2026 20:50
@github-project-automation github-project-automation Bot moved this from Needs Review to Done in DevX Aug 4, 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.

tx simulate re-assembly: re-record auth and avoid double-counting the resource fee

3 participants