Skip to content

feat: add /v3/transactions/simulate endpoint#7424

Open
brice-stacks wants to merge 8 commits into
stacks-network:developfrom
brice-stacks:feat/txsimulate
Open

feat: add /v3/transactions/simulate endpoint#7424
brice-stacks wants to merge 8 commits into
stacks-network:developfrom
brice-stacks:feat/txsimulate

Conversation

@brice-stacks

Copy link
Copy Markdown
Contributor

Added a new authenticated RPC endpoint POST /v3/transactions/simulate which simulates a single transaction on top of the canonical chain tip (discarding all state changes) and reports its result, events, and execution cost.

Applicable issues

Additional info (benefits, drawbacks, caveats)

Checklist

  • Test coverage for new or modified code paths
  • For new Clarity features or consensus changes, add property tests (see docs/property-testing.md)
  • Changelog fragment(s) or "no changelog" label added (see changelog.d/README.md)
  • Required documentation changes (e.g., rpc/openapi.yaml for RPC endpoints, event-dispatcher.md for new events)
  • New clarity functions have corresponding PR in clarity-benchmarking repo

Added a new authenticated RPC endpoint `POST /v3/transactions/simulate`
which simulates a single transaction on top of the canonical chain tip
(discarding all state changes) and reports its result, events, and
execution cost.

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

Adds a new authenticated RPC endpoint to simulate a single signed Stacks transaction against the canonical chain tip, returning the execution result, events, and execution cost without persisting any state.

Changes:

  • Implement POST /v3/transactions/simulate request/response handling and simulation logic in an ephemeral Nakamoto tenure/block context.
  • Register the endpoint in the RPC router and add API tests covering success + auth/nonce failures.
  • Document the endpoint in OpenAPI and add a changelog fragment.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
stackslib/src/net/api/txsimulate.rs Implements the new /v3/transactions/simulate RPC handler, simulation logic, and client request/response helpers.
stackslib/src/net/api/tests/txsimulate.rs Adds tests for request parsing, error cases, and successful simulation behavior.
stackslib/src/net/api/tests/mod.rs Wires the new txsimulate test module into the API test suite.
stackslib/src/net/api/mod.rs Registers the new RPC endpoint in StacksHttp.
docs/rpc/openapi.yaml Documents the new endpoint contract and response shape.
changelog.d/tx-simulate-endpoint.added Changelog entry announcing the new endpoint.

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

Comment thread stackslib/src/net/api/txsimulate.rs Outdated
Comment thread docs/rpc/openapi.yaml
Make `from_receipt` return a `Result` and properly handle a json
serialization failure.

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment thread stackslib/src/net/api/txsimulate.rs Outdated
Comment thread docs/rpc/openapi.yaml

@francesco-stacks francesco-stacks 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.

Overall LGTM, just a couple of points:

  • the OpenAPI CI step is failing
  • could we also add the same memory limit mechanism we use on the miners/signers to guarantee that the transaction we are executing actually stays within the limits and would be accepted by the miners/singers?

Comment thread stackslib/src/net/api/txsimulate.rs Outdated

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

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

Comment thread stackslib/src/net/api/tests/txsimulate.rs
Comment thread docs/rpc/openapi.yaml
Comment thread docs/rpc/openapi.yaml Outdated
brice-stacks and others added 2 commits July 21, 2026 11:20
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread stackslib/src/net/api/txsimulate.rs
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 29847442772

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage increased (+0.8%) to 86.522%

Details

  • Coverage increased (+0.8%) from the base build.
  • Patch coverage: 59 uncovered changes across 1 file (218 of 277 lines covered, 78.7%).
  • 12006 coverage regressions across 166 files.

Uncovered Changes

File Changed Covered %
stackslib/src/net/api/txsimulate.rs 275 216 78.55%
Total (2 files) 277 218 78.7%

Coverage Regressions

12006 previously-covered lines in 166 files lost coverage.

Top 10 Files by Coverage Loss Lines Losing Coverage Coverage
stackslib/src/chainstate/burn/db/sortdb.rs 641 90.47%
stackslib/src/chainstate/stacks/db/blocks.rs 525 89.96%
stackslib/src/chainstate/nakamoto/mod.rs 488 84.91%
stackslib/src/config/mod.rs 324 78.53%
stackslib/src/net/relay.rs 316 74.91%
stackslib/src/net/mod.rs 313 78.15%
stackslib/src/chainstate/stacks/index/storage.rs 277 82.41%
stackslib/src/chainstate/stacks/db/transactions.rs 269 97.13%
clarity/src/vm/database/clarity_db.rs 268 82.27%
stackslib/src/chainstate/stacks/miner.rs 267 83.12%

Coverage Stats

Coverage Status
Relevant Lines: 231623
Covered Lines: 200405
Line Coverage: 86.52%
Coverage Strength: 19619380.13 hits per line

💛 - Coveralls

@rob-stacks

rob-stacks commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

I like it, given that the block simulation rpc endpoint supports running transactions in any arbitrary block in the chain, can we have the same feature here?

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.

5 participants