Add experimental `AnyNewEpochState` parameterised on `Era` to eliminate partial `sbeToEra` conversions
Los mantenedores suelen responder en 1 día
@carbolymer ya está trabajando en esto.
Desde el 27/4/2026.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
Problem
AnyNewEpochState in Cardano.Api.LedgerState carries a ShelleyBasedEra era witness:
data AnyNewEpochState where
AnyNewEpochState
:: ShelleyBasedEra era
-> ShelleyAPI.NewEpochState (ShelleyLedgerEra era)
-> Ledger.LedgerTables ...
-> AnyNewEpochState
Consumers in cardano-testnet that need EraCommonConstraints (via obtainCommonConstraints) must first convert ShelleyBasedEra era to Exp.Era era using sbeToEra. Because Exp.Era only inhabits Conway and Dijkstra, sbeToEra is partial for pre-Conway eras, forcing every call site to use a helper like:
unsafeEraFromSbe :: HasCallStack => ShelleyBasedEra era -> Era era
unsafeEraFromSbe = withFrozenCallStack $
either (error . prettyShow . prettyError) id . sbeToEra
This appears in EpochStateProcessing.hs and is used across multiple modules (Components/Query.hs, Runtime.hs, Process/Cli/SPO.hs). Every pattern match on AnyNewEpochState in testnet code repeats the same partial conversion.
See cardano-node PR #6551 for context and the review discussion that motivated this issue.
Constraint
foldEpochState replays the chain from genesis via a pipelined chain-sync client. The callback receives blocks from all eras (Shelley through Dijkstra), so the existing AnyNewEpochState with ShelleyBasedEra must remain available for consumers that need full-era coverage (e.g. cardano-cli debug log-epoch-state).
Proposal
Add a new existential type in Cardano.Api.Experimental that carries an Era era witness instead of ShelleyBasedEra era:
-- | Like 'AnyNewEpochState' but restricted to experimental (Conway+) eras,
-- so that 'obtainCommonConstraints' is always total.
data AnyNewEpochState where
AnyNewEpochState
:: Era era
-> ShelleyAPI.NewEpochState (ShelleyLedgerEra era)
-> Ledger.LedgerTables ...
-> AnyNewEpochState
Optionally, provide one or both of:
- A conversion function from the legacy type to
Maybethe experimental type (fails for pre-Conway eras). - A wrapper around
foldEpochStatethat silently skips pre-Conway blocks and delivers onlyExp.AnyNewEpochStateto the callback, for consumers that only care about Conway+ governance state.
Migration path
- cardano-testnet: switch to the experimental
AnyNewEpochState. AllunsafeEraFromSbecalls and the helper itself can be removed;obtainCommonConstraintsworks directly on theErawitness. - cardano-cli (
debug log-epoch-state): continues using the legacyAnyNewEpochStatewithShelleyBasedEra, unaffected by this change.
Alternatives considered
- Make
sbeToEratotal: not possible without adding pre-Conway constructors toEra, which defeats the purpose of the experimental API. - Keep the status quo: every new testnet module repeats the same partial conversion boilerplate, and
errorcalls in test infrastructure are fragile.
- Lenguaje dominante
- Haskell
- Estrellas
- 41
- Forks
- 32
- Merge medio
- 2 d 19 h
- PR fusionados (30 d)
- 29
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de IntersectMBO/cardano-api
-
Dificultad 4/5 3-5 días Aptitud para principiantes 52/100
IntersectMBO/cardano-api#1393 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
IntersectMBO/cardano-api#1386 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
IntersectMBO/cardano-api#1382 ·
Los mantenedores suelen responder en 1 día
-
cardano-rpc: split a lightweight client package out of the serverQuizá libre de nuevo @carbolymer la tomó hace 43 días y no hay ningún pull request abierto. Abiertorefactor
IntersectMBO/cardano-api#1339 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Transaction builders accept duplicate TxIns with differing witnesses, producing transactions rejected with ExtraRedeemersQuizá libre de nuevo @carbolymer la tomó hace 53 días y no hay ningún pull request abierto. Abiertobug
IntersectMBO/cardano-api#1324 · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de IntersectMBO/cardano-api
Issues similares
-
MorphRule, DataizeRule and ContextualizeRule silently accept unknown YAML keys, unlike rewrite `Rule`Posiblemente ocupada @renyamamoto2026-cmyk la tomó hace 1 día. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
objectionary/phino#2107 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
tweag/tricorder#640 · 1 comentario ·
Los mantenedores suelen responder en 1 día