Skip to content

Add --auth-mode flag for tx simulation#2602

Open
mootz12 wants to merge 2 commits into
mainfrom
support-non-root-auth
Open

Add --auth-mode flag for tx simulation#2602
mootz12 wants to merge 2 commits into
mainfrom
support-non-root-auth

Conversation

@mootz12
Copy link
Copy Markdown
Contributor

@mootz12 mootz12 commented Jun 3, 2026

What

Add an optional --auth-mode flag (and STELLAR_AUTH_MODE env var) to the commands that simulate Soroban transactions: contract invoke, contract deploy, contract upload, and tx simulate. Accept three modes:

  • enforce — validate the authorization entries already on the transaction.
  • root — record authorization entries, requiring each to be rooted at the transaction's top-level operation.
  • non-root — record all authorization entries, including non-root sub-invocation auth.

Thread the selected mode into the RPC simulateTransaction authMode parameter through simulate_and_assemble_transaction. Leave the flag unset by default so None is passed and existing behavior is unchanged.

Keep the flag off extend/restore, which do not produce InvokeHostFunction operations and which the RPC rejects an authMode for.

Why

Fixes #2574

The CLI is a developer-focused tool, but it previously had a single, fixed behavior for simulating Soroban authorization and could not produce, sign, or submit transactions that use non-root authorization. Exposing the RPC's auth modes lets developers opt into non-root authorization (and explicit enforce/record behavior) on the commands that build and simulate transactions.

Known limitations

  • enforce auth mode is not valid on invoke/deploy/upload. It was kept to avoid having duplicate auth mode structs for simulation and invoke commands, and to match the RPC's interface.

Copilot AI review requested due to automatic review settings June 3, 2026 19:23
@github-project-automation github-project-automation Bot moved this to Backlog (Not Ready) in DevX Jun 3, 2026
@mootz12 mootz12 requested a review from fnando June 3, 2026 19:23
@claude
Copy link
Copy Markdown

claude Bot commented Jun 3, 2026

Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 689fb7b5ca

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

&tx,
resource_config,
None,
self.auth_mode.to_rpc(),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Replace existing auth when recording simulations

When tx simulate --auth-mode=root|non-root is used on an envelope that already contains auth entries (for example re-recording a partially authorized transaction to capture non-root sub-invocation auth), the RPC can return freshly recorded auth but the assembled output keeps the original entries because assemble only copies simulation.results[*].auth when body.auth.is_empty(). Passing the new record modes here therefore prints an XDR that is still missing the newly recorded authorization entries; the assembly path needs to know when an explicit record mode should replace existing auth instead of preserving it.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is correct but out of scope for the PR. tracking in another issue to fix the few things wrong with re-simulation: #2603

Copy link
Copy Markdown
Contributor

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 adds a shared --auth-mode flag (and STELLAR_AUTH_MODE env var) to control Soroban RPC simulateTransaction.authMode behavior for transaction-simulating CLI commands, enabling users to explicitly choose between enforcing existing auth entries vs recording root/non-root auth during simulation while keeping the default behavior unchanged when unset.

Changes:

  • Introduces a reusable auth_mode argument module that maps CLI values (enforce, root, non-root) to soroban_rpc::AuthMode.
  • Threads the selected auth mode through simulate_and_assemble_transaction into the RPC simulation call.
  • Adds/updates integration tests covering the new modes and env-var behavior, and updates generated help docs.

Reviewed changes

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

Show a summary per file
File Description
FULL_HELP_DOCS.md Documents --auth-mode for relevant commands and lists allowed values.
cmd/soroban-cli/src/tx.rs Extends sim_sign_and_send_tx to accept and forward an optional RPC auth mode.
cmd/soroban-cli/src/lib.rs Exposes the new auth_mode module.
cmd/soroban-cli/src/commands/tx/simulate.rs Adds --auth-mode support to tx simulate and passes it into simulation.
cmd/soroban-cli/src/commands/contract/upload.rs Adds --auth-mode support to contract upload and forwards it to tx simulation.
cmd/soroban-cli/src/commands/contract/restore.rs Explicitly passes None auth mode for restore ops (RPC rejects authMode).
cmd/soroban-cli/src/commands/contract/invoke.rs Adds --auth-mode support to contract invoke for both simulation-only and send paths.
cmd/soroban-cli/src/commands/contract/extend.rs Explicitly passes None auth mode for extend ops (RPC rejects authMode).
cmd/soroban-cli/src/commands/contract/deploy/wasm.rs Adds --auth-mode support to wasm deploy and forwards it through simulation/send flow.
cmd/soroban-cli/src/commands/contract/deploy/asset.rs Updates call site for new sim_sign_and_send_tx signature (keeps auth mode unset).
cmd/soroban-cli/src/auth_mode.rs New shared clap args + enum mapping into soroban_rpc::AuthMode, with unit tests.
cmd/soroban-cli/src/assembled.rs Adds optional auth mode parameter and passes it into the RPC simulation call.
cmd/crates/soroban-test/tests/it/integration/tx/general.rs Updates signature usage and adds tests covering tx simulate auth-mode behaviors.
cmd/crates/soroban-test/tests/it/integration/auth.rs Adds integration tests for non-root auth mode (flag + env var) enabling successful signing/subcalls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog (Not Ready)

Development

Successfully merging this pull request may close these issues.

Add auth modes for authorization

2 participants