Skip to content

Complete the era eons for Dijkstra - #1298

Open
palas wants to merge 4 commits into
masterfrom
complete-dijkstra-eons
Open

Complete the era eons for Dijkstra#1298
palas wants to merge 4 commits into
masterfrom
complete-dijkstra-eons

Conversation

@palas

@palas palas commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Context

Make DijkstraEra a first-class era in cardano-api: everywhere the API dispatches on eras, Dijkstra now takes a real branch instead of hitting a TODO stub.

This is groundwork: it adds no Dijkstra-specific features, it makes them possible to build. Dijkstra stays hidden from era enumeration (maxBound is still Conway); exposing it there comes in a later PR.

One known gap is left on purpose: simple scripts remain unsupported in Dijkstra: they need the era's new guard construct in SimpleScript first, which deserves its own design discussion.

How to trust this PR

Almost all of this is interpolation of the previous eras. Two exceptions:

  1. The eon constraint bundles no longer provide ShelleyEraTxCert/TxCert ~ ConwayTxCert (Dijkstra dropped those certificates), so a few call sites now require them explicitly. This is the breaking part.
  2. Dijkstra replaced required signer hashes with guards, so the tx-body lens has no Dijkstra arm (like the ledger's) and createTransactionBody translates TxExtraKeyWitnesses into key-hash guards (Body.hs, Body/Lens.hs).

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff
  • Changelog fragment added in .changes/

@palas palas self-assigned this Aug 19, 2026
@palas
palas force-pushed the complete-dijkstra-eons branch from a1bfe46 to cb50408 Compare August 19, 2026 02:38
Copilot AI lite review requested due to automatic review settings August 19, 2026 02:38

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

This PR completes the “era eon” coverage for DijkstraEra across cardano-api so that era-dispatching code paths no longer hit TODO stubs, and updates transaction-building behavior to reflect ledger changes in Dijkstra (required signer hashes replaced by guards). It also updates constraint bundles to reflect that Dijkstra no longer supports ShelleyEraTxCert / TxCert ~ ConwayTxCert, and includes a changelog fragment marking the change as breaking.

Changes:

  • Implement Dijkstra branches in era-dispatch helpers and eon instances (so Dijkstra participates wherever era dispatch happens, while still not being added to bounded era enumeration).
  • Adjust tx-body handling for extra key witnesses in Dijkstra by translating them into key-hash guards; stub the required-signer-hashes lens for Dijkstra like the ledger does.
  • Update eon constraint bundles to drop ShelleyEraTxCert / TxCert ~ ConwayTxCert where Dijkstra cannot satisfy them; add a .changes/ fragment marking this as breaking.

Reviewed changes

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

Show a summary per file
File Description
cardano-api/src/Cardano/Api/Tx/Internal/Output.hs Add Dijkstra support to TxOut conversion to/from ledger types.
cardano-api/src/Cardano/Api/Tx/Internal/Body/Lens.hs Stub required-signer-hashes lens for Dijkstra; use common constraints for Conway/Dijkstra governance-related lenses.
cardano-api/src/Cardano/Api/Tx/Internal/Body.hs Translate TxExtraKeyWitnesses into Dijkstra tx-body guards instead of required signer hashes.
cardano-api/src/Cardano/Api/LedgerState.hs Add Dijkstra branch for nonce/entropy selection in leadership-slot calculation.
cardano-api/src/Cardano/Api/Internal/Orphans/Serialisation.hs Add ToJSON instance for Dijkstra ledger predicate failures.
cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Certificate/Compatible.hs Tighten certificate helper constraints (but still contains a Dijkstra-era TODO stub).
cardano-api/src/Cardano/Api/Experimental/Era.hs Add Dijkstra handling to experimental-era eon dispatch.
cardano-api/src/Cardano/Api/Era/Internal/Eon/ShelleyBasedEra.hs Enable Dijkstra in Shelley-based eon witness equality and constraints dispatch; remove ShelleyEraTxCert from the shared bundle.
cardano-api/src/Cardano/Api/Era/Internal/Eon/MaryEraOnwards.hs Enable Dijkstra in Mary-era onwards eon and relax constraints to exclude ShelleyEraTxCert.
cardano-api/src/Cardano/Api/Era/Internal/Eon/ConwayEraOnwards.hs Enable Dijkstra in Conway-era onwards eon and remove ShelleyEraTxCert / TxCert ~ ConwayTxCert constraints.
cardano-api/src/Cardano/Api/Era/Internal/Eon/BabbageEraOnwards.hs Enable Dijkstra in Babbage-era onwards eon and adjust cert constraints to use EraTxCert.
cardano-api/src/Cardano/Api/Era/Internal/Eon/AlonzoEraOnwards.hs Add IsAlonzoBasedEra DijkstraEra instance.
cardano-api/src/Cardano/Api/Era/Internal/Eon/AllegraEraOnwards.hs Enable Dijkstra in Allegra-era onwards eon and adjust cert constraints to use EraTxCert.
cardano-api/src/Cardano/Api/Era/Internal/Core.hs Add TestEquality support for DijkstraEra.
cardano-api/src/Cardano/Api/Era/Internal/Case.hs Route Dijkstra through existing era-case helpers and add a new case helper name.
cardano-api/src/Cardano/Api/Era.hs Re-export the new era-case helper.
.changes/20260818_120100_cardano-api_palas_dijkstra_eon_completion.yml Changelog fragment documenting feature + breaking constraint-bundle change.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cardano-api/src/Cardano/Api/Era/Internal/Case.hs Outdated
Comment thread cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Certificate/Compatible.hs Outdated
@palas
palas force-pushed the complete-dijkstra-eons branch 2 times, most recently from dc66805 to 7dcad4d Compare August 19, 2026 03:18
Comment thread cardano-api/src/Cardano/Api/Era/Internal/Eon/AllegraEraOnwards.hs Outdated
Comment thread cardano-api/src/Cardano/Api/Era/Internal/Eon/BabbageEraOnwards.hs Outdated
Comment thread cardano-api/src/Cardano/Api/Era/Internal/Eon/MaryEraOnwards.hs Outdated
Comment thread cardano-api/src/Cardano/Api/Era/Internal/Eon/ShelleyBasedEra.hs Outdated

@carbolymer carbolymer 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.

We need a new eons ending at Conway for that, because there are breaking changes in Dijkstra. But I guess @Jimbo4350 would not like that.

Comment thread cardano-api/src/Cardano/Api/Experimental/Era.hs
Comment thread cardano-api/src/Cardano/Api/Tx/Internal/Body/Lens.hs
Comment thread cardano-api/src/Cardano/Api/Tx/Internal/Body.hs
, L.EraGov (ShelleyLedgerEra era)
, L.ShelleyEraTxCert (ShelleyLedgerEra era)
, FromCBOR (Consensus.ChainDepState (ConsensusProtocol era))
, -- L.ShelleyEraTxCert dropped: gated by AtMostEra "Conway" in the ledger, so

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.

I'm not seeing a Dijkstra ShelleyEraTxCert instance in cardano-ledger. Where are you getting the "gated by AtMostEra "Conway" in the ledger" from? Have you asked the ledger about the implementation of this instance?

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.

I haven't asked, but it is here: https://cardano-ledger.cardano.intersectmbo.org/cardano-ledger-shelley/Cardano-Ledger-Shelley-TxCert.html#t:ShelleyEraTxCert

Documentation also says: All of the Shelley related certificate functionality that has been fully deprecated in Dijkstra.

Comment thread cardano-api/src/Cardano/Api/Tx/Internal/Body/Lens.hs
Comment thread cardano-api/src/Cardano/Api/Tx/Internal/Body.hs
Base automatically changed from skip-drep-query-when-not-needed to master August 19, 2026 19:32
Mostly interpolation of the previous eras: every eon dictionary and
case eliminator gets its Dijkstra arm (the
Allegra/Mary/Babbage/Conway-onwards dictionaries return `id`), plus
the `IsAllegra/Mary/Alonzo/BabbageBasedEra` instances, `TestEquality`
on `CardanoEra`, the experimental `Era`'s `Eon` instance, the `ToJSON`
`DijkstraLedgerPredFailure` instance the `ShelleyBasedEra` bundle
needs, the Dijkstra arms in the `TxOut` conversions and tx-body lenses
that the relaxation below makes reachable, and a Dijkstra arm
mirroring Conway in `makeStakeAddressDelegationCertificate`.

Two real changes. First, the ledger gates Shelley-style certificates
to `AtMostEra "Conway"`, so the eon constraint bundles no longer
provide `ShelleyEraTxCert` or `TxCert ~ ConwayTxCert` (breaking); call
sites that need them now require them explicitly. Second, Dijkstra
replaced required signer hashes with guards, so
`reqSignerHashesTxBodyL` has no working Dijkstra arm (mirroring the
ledger's own gate) and `createTransactionBody` instead translates
`TxExtraKeyWitnesses` into appended key-hash guards.

Simple scripts stay unsupported in Dijkstra: they need the era's new
guard construct in `SimpleScript` first. That also keeps
`txOutParseJson` unsupported, since Dijkstra tx outs can carry
reference scripts of the new native-script type.

Co-Authored-By: Sebastian Nagel <sebastian.nagel@ncoding.at>
Co-Authored-By: kderme <k.dermenz@gmail.com>
Co-Authored-By: Konstantinos Lambrou-Latreille <konstantinos.lambrou@iohk.io>
Co-Authored-By: John Lotoski <john.lotoski@iohk.io>
Co-Authored-By: Mateusz Galazyn <mateusz.galazyn@iohk.io>
@palas
palas force-pushed the complete-dijkstra-eons branch from 7dcad4d to d8ba5e9 Compare August 19, 2026 19:32
palas added 2 commits August 20, 2026 02:14
Drop the four constraint comments, deprecate cardano-api's
reqSignerHashesTxBodyL in favour of the ledger's lens and getter (the
old-API construction site now uses the ledger lens per era), pattern
match explicitly instead of using a wildcard in createTransactionBody's
required-signers case, and fix the Enum (Some Era) roundtrip
(toEnum 1 = Some DijkstraEra) while keeping maxBound at Conway.
Every wrapper that just re-dresses a ledger lens is deprecated in
favour of the ledger's own, and createTransactionBody now uses the
ledger lenses directly. Cardano.Api.Ledger gains the re-exports the
migration needs: the era tx-body classes, the affected lenses,
valueTxOutL and coinTxOutL. Kept undeprecated: the validity-interval
compatibility lenses, adaAssetL and multiAssetL, which have no ledger
equivalent (and adaAssetL is still used by cardano-testnet).
Comment on lines +1337 to +1350
in monoidForEraInEonA era $ \w -> case w of
-- Dijkstra replaced required signer hashes with guards, and a key-hash
-- guard makes the ledger demand that key's signature: translate, appending
-- so any other guards stay intact.
AlonzoEraOnwardsDijkstra ->
pure . Endo $
A.txBodyL . L.guardsTxBodyL
%~ (<> OSet.fromSet (Set.map Shelley.KeyHashObj keyWits))
AlonzoEraOnwardsAlonzo ->
pure $ Endo $ A.txBodyL . L.reqSignerHashesTxBodyL .~ keyWits
AlonzoEraOnwardsBabbage ->
pure $ Endo $ A.txBodyL . L.reqSignerHashesTxBodyL .~ keyWits
AlonzoEraOnwardsConway ->
pure $ Endo $ A.txBodyL . L.reqSignerHashesTxBodyL .~ keyWits
After the lens migration, mScriptIntegrityHash's only type-fixing use
sits under alonzoEraOnwardsConstraints, and older GHCs refuse to unify
the outer type variable there (it is untouchable under the constraint
implication); GHC 9.12+ solves it anyway. Pin the type at the binder
instead.
@palas
palas requested review from Jimbo4350 and carbolymer August 20, 2026 01:29
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