Skip to content

Further StAnnTx integration#5857

Open
teodanciu wants to merge 13 commits into
masterfrom
td/further-stanntx-integration
Open

Further StAnnTx integration#5857
teodanciu wants to merge 13 commits into
masterfrom
td/further-stanntx-integration

Conversation

@teodanciu

@teodanciu teodanciu commented May 21, 2026

Copy link
Copy Markdown
Contributor

Description

So far, integration of StAnnTx - which means using the memoized values that it holds - has been done for eras starting with Babbage (#5804).
Alonzo is problematic because the EpochInfo used when creating plutus contexts in Alonzo is modified with unsafeLinearExtendEpochInfo, which depends on the slot number.
Passing the slot number when creating the StAnnTx turned out to be an incorrect solution, because that would make the memoized version dependent on the environment.
Instead, in this PR, the problem is handled by pushing the discrepancy more at the "edges" - namely modifying the EpochInfo via unsafeLinearExtendEpochInfo at the entry points: in ApplyTx and LEDGERS rule for alonzo.

ApplyTx has been restructured (old methods deprecated), in order to facilitate the change we needed ,and also to provide better names, as follows:

applyTxValidation deprecated in favor of applyTxWithValidation
applyTx deprecated in favour of applyTxWithFullValidation
reapplyTx deprecated in favor of reapplyValidatedTx
unsafeMakeValidated deprecated in favor of unsafeMakeValidatedTx

A new method was added to ApplyTx: reapplyTxFromValidated - for full per-era flexibility and safety.

A new AlonzoLEDGERS had to be introduced instead of reusing ShelleyLEDGERS, that passes the unsafeLinearExtendEpochInfo modification.

Finally, the memoized plutus contexts have been reused in Alonzo UTXOS.

Closes #5836

Checklist

  • Commits in meaningful sequence and with useful messages.
  • Tests added or updated when needed.
  • CHANGELOG.md files updated for packages with externally visible changes.
    NOTE: New section is never added with the code changes. (See RELEASING.md).
  • Versions updated in .cabal and CHANGELOG.md files when necessary, according to the
    versioning process.
  • Version bounds in .cabal files updated when necessary.
    NOTE: If bounds change in a cabal file, that package itself must have a version increase. (See RELEASING.md).
  • Code formatted (use scripts/fourmolize.sh).
  • Cabal files formatted (use scripts/cabal-format.sh).
  • CDDL files are up to date (use scripts/gen-cddl.sh)
  • hie.yaml updated (use scripts/gen-hie.sh).
  • Self-reviewed the diff.

@teodanciu teodanciu force-pushed the td/further-stanntx-integration branch 5 times, most recently from 5af319a to bc54d6a Compare May 22, 2026 21:53
@teodanciu teodanciu changed the title [wip] Further StAnnTx integration Further StAnnTx integration May 22, 2026
@teodanciu teodanciu marked this pull request as ready for review May 22, 2026 21:53
@teodanciu teodanciu requested a review from a team as a code owner May 22, 2026 21:53
Comment thread eras/shelley/impl/src/Cardano/Ledger/Shelley/API/Mempool.hs Outdated

@lehins lehins left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'll finish the review later when I am back to work on Wednesday

Comment thread eras/shelley/impl/src/Cardano/Ledger/Shelley/API/Mempool.hs Outdated
Comment thread eras/shelley/impl/src/Cardano/Ledger/Shelley/API/Mempool.hs
Comment thread eras/shelley/impl/CHANGELOG.md Outdated
Comment thread eras/shelley/impl/src/Cardano/Ledger/Shelley/API/Mempool.hs Outdated
Comment thread eras/shelley/impl/src/Cardano/Ledger/Shelley/API/Mempool.hs Outdated
Copilot AI review requested due to automatic review settings May 28, 2026 10:37
@teodanciu teodanciu force-pushed the td/further-stanntx-integration branch from bc54d6a to df72280 Compare May 28, 2026 10:37

Copilot AI left a comment

Copy link
Copy Markdown

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 continues StAnnTx integration by introducing ValidatedTx, updating mempool transaction application/reapplication APIs, and wiring Alonzo-specific handling for slot-dependent Plutus context construction at ledger entry points.

Changes:

  • Adds/deprecates ApplyTx/mempool APIs around ValidatedTx and reusable default implementations.
  • Introduces AlonzoLEDGERS and updates Alonzo UTXOS to consume memoized Plutus contexts from StAnnTx.
  • Updates era instances, tests, benchmarks, and changelogs to use the new APIs and removed memoized protocol-version fields.

Reviewed changes

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

Show a summary per file
File Description
libs/ledger-state/bench/Performance.hs Updates benchmark transaction application/reapplication to new validated transaction APIs.
libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/MockChain.hs Adds embedding support for AlonzoLEDGERS.
libs/cardano-ledger-test/benchProperty/Main.hs Imports Alonzo trace instances for benchmark properties.
libs/cardano-ledger-test/bench/Bench/Cardano/Ledger/ApplyTx.hs Switches apply benchmark to applyTxWithFullValidation.
eras/shelley/test-suite/src/Test/Cardano/Ledger/Shelley/Generator/Trace/Ledger.hs Extracts reusable ledgersSigGen.
eras/shelley/test-suite/CHANGELOG.md Documents the new test generator helper.
eras/shelley/impl/src/Cardano/Ledger/Shelley/API/Mempool.hs Adds ValidatedTx, new apply/reapply APIs, defaults, and deprecations.
eras/shelley/impl/CHANGELOG.md Documents mempool API changes.
eras/mary/impl/src/Cardano/Ledger/Mary.hs Uses default ApplyTx implementations.
eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/Tx.hs Removes protocol version from Dijkstra StAnnTx.
eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra.hs Uses default mempool implementations and updated StAnnTx.
eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/LedgerSpec.hs Updates tests to use full validation API.
eras/conway/impl/src/Cardano/Ledger/Conway.hs Uses default mempool implementations.
eras/babbage/impl/src/Cardano/Ledger/Babbage/Rules/Utxos.hs Adapts UTXOS environment after removing ueUtxo.
eras/babbage/impl/src/Cardano/Ledger/Babbage/Rules/Utxo.hs Updates UTXOS transition environment construction.
eras/babbage/impl/src/Cardano/Ledger/Babbage.hs Uses default ApplyTx implementations.
eras/alonzo/test-suite/src/Test/Cardano/Ledger/Alonzo/Trace.hs Adds trace support for AlonzoLEDGERS.
eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/TreeDiff.hs Updates AlonzoStAnnTx tree diff after field removal.
eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Tx.hs Removes protocol version from AlonzoStAnnTx.
eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Utxos.hs Reuses memoized Plutus scripts/contexts from StAnnTx.
eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Utxo.hs Updates UTXOS environment construction.
eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Ledgers.hs Implements new Alonzo-specific LEDGERS rule.
eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules.hs Re-exports the new Alonzo LEDGERS rule module.
eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Era.hs Maps Alonzo LEDGERS to AlonzoLEDGERS.
eras/alonzo/impl/src/Cardano/Ledger/Alonzo.hs Adds Alonzo-specific validation/reapplication behavior and updated StAnnTx.
eras/alonzo/impl/CHANGELOG.md Documents Alonzo rule/environment changes.
eras/allegra/impl/src/Cardano/Ledger/Allegra.hs Uses default ApplyTx implementations.

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

Comment thread eras/shelley/impl/src/Cardano/Ledger/Shelley/API/Mempool.hs Outdated
Comment thread eras/alonzo/impl/src/Cardano/Ledger/Alonzo.hs Outdated
@teodanciu teodanciu force-pushed the td/further-stanntx-integration branch from df72280 to cc97f3d Compare May 28, 2026 11:32
@teodanciu teodanciu force-pushed the td/further-stanntx-integration branch 7 times, most recently from 47b3a9c to 57e8230 Compare June 18, 2026 16:31
@teodanciu teodanciu force-pushed the td/further-stanntx-integration branch from 57e8230 to fd85863 Compare June 22, 2026 09:22
@teodanciu teodanciu force-pushed the td/further-stanntx-integration branch from fd85863 to df8cf07 Compare June 22, 2026 10:13
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.

Further StAnnTx integration

3 participants