refactor: encapsulate transaction processing in a typestate-based processor - #7515
Open
cylewitruk-stacks wants to merge 5 commits into
Open
refactor: encapsulate transaction processing in a typestate-based processor#7515cylewitruk-stacks wants to merge 5 commits into
cylewitruk-stacks wants to merge 5 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors transaction execution into a typestate-based processor while preserving consensus behavior and enabling Clarity tracing.
Changes:
- Adds
TransactionProcessor, processing modules, and compile-fail coverage. - Migrates transaction-processing callers and propagates evaluation hooks.
- Clarifies resource-budget and microblock signer APIs.
Reviewed changes
Copilot reviewed 29 out of 30 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
stackslib/src/net/api/postblock_proposal.rs |
Updates resource-budget construction. |
stackslib/src/net/api/fastcallreadonly.rs |
Updates read-only execution budgets. |
stackslib/src/net/api/callreadonly.rs |
Updates read-only execution budgets. |
stackslib/src/clarity_vm/clarity.rs |
Adds evaluation hooks and processor integration. |
stackslib/src/chainstate/tests/static_analysis_tests.rs |
Updates processor references. |
stackslib/src/chainstate/tests/runtime_analysis_tests.rs |
Updates budget documentation. |
stackslib/src/chainstate/tests/mod.rs |
Migrates test transaction processing. |
stackslib/src/chainstate/tests/consensus.rs |
Updates TxToProcess import. |
stackslib/src/chainstate/stacks/mod.rs |
Re-exports signer comparison type. |
stackslib/src/chainstate/stacks/miner.rs |
Migrates miner processing and budgets. |
stackslib/src/chainstate/stacks/db/transactions/processing/validation.rs |
Extracts static validation. |
stackslib/src/chainstate/stacks/db/transactions/processing/tests/typestate_compile_fail.rs |
Adds invalid-typestate tests. |
stackslib/src/chainstate/stacks/db/transactions/processing/tests/mod.rs |
Registers processing tests. |
stackslib/src/chainstate/stacks/db/transactions/processing/post_conditions.rs |
Extracts post-condition evaluation. |
stackslib/src/chainstate/stacks/db/transactions/processing/poison_microblock.rs |
Extracts poison-microblock handling. |
stackslib/src/chainstate/stacks/db/transactions/processing/payload.rs |
Extracts payload execution. |
stackslib/src/chainstate/stacks/db/transactions/processing/mod.rs |
Implements processor typestates. |
stackslib/src/chainstate/stacks/db/transactions/processing/accounts.rs |
Extracts account and fee operations. |
stackslib/src/chainstate/stacks/db/transactions.rs |
Exposes processor and migrates tests. |
stackslib/src/chainstate/stacks/db/mod.rs |
Migrates boot transaction processing. |
stackslib/src/chainstate/stacks/db/blocks.rs |
Migrates block and mempool processing. |
stackslib/src/chainstate/nakamoto/mod.rs |
Relocates TxToProcess. |
stackslib/src/chainstate/nakamoto/miner.rs |
Uses processor receipt checks. |
stacks-node/src/tests/mem_abort.rs |
Updates test budget construction. |
stacks-node/src/nakamoto_node/miner.rs |
Uses an in-memory test database. |
stacks-codec/src/transaction.rs |
Adds microblock signer comparison. |
clarity/src/vm/resource_limiter.rs |
Clarifies unlimited budget construction. |
clarity/src/vm/mod.rs |
Updates execution budget construction. |
clarity/src/vm/analysis/type_checker/v2_1/tests/mod.rs |
Updates deadline test budgets. |
clarity/src/vm/analysis/tests/mod.rs |
Updates analysis test budgets. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 29 out of 30 changed files in this pull request and generated no new comments.
Suppressed comments (3)
clarity/src/vm/resource_limiter.rs:181
- Removing the public
new()constructor andDefaultimplementation makes this release source-incompatible for downstreamclarityconsumers, even though both had exactly the same semantics asunlimited(). Retain compatibility shims (they can be deprecated) so this refactor does not force unrelated consumer changes.
impl ResourceBudget {
/// Creates a new instance with no configured budgets.
pub fn unlimited() -> Self {
Self {
max_duration: None,
stackslib/src/chainstate/stacks/db/transactions/processing/tests/typestate_compile_fail.rs:17
- The explicit intra-doc target points at the
testsmodule, butTransactionProcessoris defined in its parent (processing). This link is unresolved when rustdoc processes the compile-fail module; point it up two module levels.
//! Compile-fail coverage for invalid [`TransactionProcessor`](super::TransactionProcessor)
//! typestate transitions.
stackslib/src/chainstate/stacks/miner.rs:789
- This removes the existing public
TransactionResourceBudgets::new()API even though its behavior is still represented byunlimited(). Downstream stackslib users will fail to compile for a naming-only change; retain a deprecated forwarding constructor while migrating in-repository callers.
impl TransactionResourceBudgets {
/// Creates resource budgets with no configured limits.
pub fn unlimited() -> Self {
Self {
execution_budget: ResourceBudget::unlimited(),
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduce a typestate-based
TransactionProcessorthat encapsulates Stacks transaction processing, makes invalid configurations unrepresentable at compile time, and supports attaching Clarity evaluation hooks (including execution tracers).This provides the
stackslibprocessing foundation for transaction trace replay (secondary) while providing a little more structure and compile-time safety for the primary transaction processing interface (primary).This is 99% a structural refactor and isn't intended to change any functionality aside from the optional eval-hook wire-up.
Changes
StacksChainStateintoTransactionProcessor.TxToProcess.StacksMicroblockHeader.Checklist