Add Ord instances for predicate failures#5850
Conversation
d1e99a6 to
248a305
Compare
3f10827 to
ea23c32
Compare
ea23c32 to
15368f5
Compare
There was a problem hiding this comment.
Pull request overview
This PR enables using Sets of STS predicate failures by requiring Ord on PredicateFailure throughout the ledger/STS stack. To accomplish that, it introduces new Ord constraints/instances across eras and core types (including Plutus-related types), and updates package bounds where needed.
Changes:
- Tighten
STSto requireOrd (PredicateFailure a)and propagateOrdrequirements through test helpers and STS instances. - Add
Ordinstances for many predicate-failure types and embedded ledger/core types (e.g., scripts, tx outputs, memoized wrappers, Plutus types). - Update cabal bounds/dependencies (notably
cardano-crypto-classand adddeepseqto a testlib whereNFDatais derived).
Reviewed changes
Copilot reviewed 116 out of 116 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| libs/small-steps/testlib/Test/Control/State/Transition/Trace.hs | Update doctest examples to derive Ord for predicate failures. |
| libs/small-steps/test/Test/Control/State/Transition/Examples/Sum.hs | Example predicate failure derives Ord. |
| libs/small-steps/test/Test/Control/State/Transition/Examples/GlobalSum.hs | Example predicate failure derives Ord. |
| libs/small-steps/test/Test/Control/State/Transition/Examples/CommitReveal.hs | Predicate failure derives Ord. |
| libs/small-steps/src/Control/State/Transition/Extended.hs | Change STS superclass constraint from Eq to Ord; update STUB accordingly. |
| libs/cardano-protocol-tpraos/testlib/Test/Cardano/Protocol/Crypto/VRF/Fake.hs | Add NFData instances for FakeVRF associated types. |
| libs/cardano-protocol-tpraos/src/Cardano/Protocol/TPraos/Rules/Updn.hs | Predicate failure derives Ord. |
| libs/cardano-protocol-tpraos/src/Cardano/Protocol/TPraos/Rules/Prtcl.hs | Add Ord derivations for predicate failures and related failures. |
| libs/cardano-protocol-tpraos/src/Cardano/Protocol/TPraos/Rules/Overlay.hs | Add Ord derivation for predicate failure. |
| libs/cardano-protocol-tpraos/src/Cardano/Protocol/TPraos/Rules/OCert.hs | Predicate failure derives Ord. |
| libs/cardano-protocol-tpraos/src/Cardano/Protocol/TPraos/BHeader.hs | LastAppliedBlock derives Ord. |
| libs/cardano-protocol-tpraos/src/Cardano/Protocol/TPraos/API.hs | FutureLedgerViewError derives Ord when underlying failures are Ord. |
| libs/cardano-protocol-tpraos/cardano-protocol-tpraos.cabal | Bump cardano-crypto-class bound and add deepseq to testlib deps. |
| libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/Properties.hs | Switch constraint from Eq to Ord for LEDGER predicate failure. |
| libs/cardano-ledger-test/src/Test/Cardano/Ledger/Generic/MockChain.hs | Switch constraints to Ord and add Ord deriving for MockChainFailure. |
| libs/cardano-ledger-core/src/Cardano/Ledger/Val.hs | Strengthen Val constraint from Eq to Ord. |
| libs/cardano-ledger-core/src/Cardano/Ledger/State/Stake.hs | Strengthen InstantStake constraint from Eq to Ord. |
| libs/cardano-ledger-core/src/Cardano/Ledger/State/Governance.hs | Add Ord deriving for FuturePParams. |
| libs/cardano-ledger-core/src/Cardano/Ledger/Plutus/TxInfo.hs | TxOutSource derives Ord. |
| libs/cardano-ledger-core/src/Cardano/Ledger/Plutus/ExUnits.hs | ExUnits'/ExUnits derive Ord. |
| libs/cardano-ledger-core/src/Cardano/Ledger/MemoBytes/Internal.hs | Add Ord instance for MemoBytes. |
| libs/cardano-ledger-core/src/Cardano/Ledger/Keys/Internal.hs | Add Ord for VKey via raw serialization ordering. |
| libs/cardano-ledger-core/src/Cardano/Ledger/Core.hs | Add Ord constraints for TxOut, Script, and NativeScript in core era classes. |
| libs/cardano-ledger-core/src/Cardano/Ledger/Compactible.hs | Require Ord (CompactForm a) in Compactible. |
| libs/cardano-ledger-core/src/Cardano/Ledger/Coin.hs | Add Ord to compact delta coin representation. |
| libs/cardano-ledger-core/src/Cardano/Ledger/Address.hs | Add Ord for Withdrawals and DirectDeposits. |
| libs/cardano-ledger-core/cardano-ledger-core.cabal | Widen cardano-crypto-class bound to allow <2.6. |
| libs/cardano-ledger-binary/cardano-ledger-binary.cabal | Widen cardano-crypto-class bound to allow <2.6. |
| libs/cardano-data/src/Data/Set/NonEmpty.hs | NonEmptySet derives Ord. |
| libs/cardano-data/src/Data/Map/NonEmpty.hs | NonEmptyMap derives Ord. |
| eras/shelley/test-suite/src/Test/Cardano/Ledger/Shelley/Rules/Chain.hs | Add Ord deriving for TestChainPredicateFailure. |
| eras/shelley/test-suite/src/Test/Cardano/Ledger/Shelley/Generator/Trace/TxCert.hs | Add Ord deriving for CertsPredicateFailure. |
| eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/ImpTest.hs | Switch LEDGER predicate failure constraint from Eq to Ord. |
| eras/shelley/impl/src/Cardano/Ledger/Shelley/TxOut.hs | Add Ord deriving for ShelleyTxOut. |
| eras/shelley/impl/src/Cardano/Ledger/Shelley/Scripts.hs | Add Ord deriving for multisig script types. |
| eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Utxow.hs | Add Ord deriving for ShelleyUtxowPredFailure. |
| eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Utxo.hs | Add Ord deriving for ShelleyUtxoPredFailure and strengthen PPUP failure constraint to Ord. |
| eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Ppup.hs | VotingPeriod and ShelleyPpupPredFailure derive Ord. |
| eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Pool.hs | ShelleyPoolPredFailure derives Ord. |
| eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Ledgers.hs | Add Ord deriving for ShelleyLedgersPredFailure. |
| eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Ledger.hs | Add Ord deriving for ShelleyLedgerPredFailure. |
| eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Delpl.hs | Add Ord deriving for ShelleyDelplPredFailure. |
| eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Delegs.hs | Add Ord deriving for ShelleyDelegsPredFailure. |
| eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Deleg.hs | ShelleyDelegPredFailure derives Ord. |
| eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Bbody.hs | Add Ord deriving for ShelleyBbodyPredFailure. |
| eras/shelley/impl/src/Cardano/Ledger/Shelley/PParams.hs | Add Ord deriving for ProposedPPUpdates. |
| eras/shelley/impl/src/Cardano/Ledger/Shelley/Governance.hs | Add Ord deriving for ShelleyGovState. |
| eras/shelley/impl/cardano-ledger-shelley.cabal | Widen cardano-crypto-class bound to allow <2.6. |
| eras/mary/impl/src/Cardano/Ledger/Mary/Value.hs | Add Ord instances for Mary value and compact forms. |
| eras/mary/impl/cardano-ledger-mary.cabal | Widen cardano-crypto-class bound to allow <2.6. |
| eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Imp.hs | Remove unused TypeApplications language pragma. |
| eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/TxInfo.hs | Add Ord deriving for DijkstraContextError. |
| eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/Tx.hs | Tighten Eq/Show constraints for DijkstraStAnnTx and use CollectError. |
| eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/Scripts.hs | Add Ord for Dijkstra native script types. |
| eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/Rules/Utxow.hs | Add Ord deriving for DijkstraUtxowPredFailure. |
| eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/Rules/Utxo.hs | Add Ord deriving for DijkstraUtxoPredFailure. |
| eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/Rules/SubUtxow.hs | Add Ord deriving for DijkstraSubUtxowPredFailure. |
| eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/Rules/SubUtxo.hs | Add Ord deriving for DijkstraSubUtxoPredFailure. |
| eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/Rules/SubPool.hs | DijkstraSubPoolPredFailure derives Ord. |
| eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/Rules/SubLedgers.hs | Add Ord deriving for DijkstraSubLedgersPredFailure. |
| eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/Rules/SubLedger.hs | Add Ord deriving for DijkstraSubLedgerPredFailure. |
| eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/Rules/SubGovCert.hs | DijkstraSubGovCertPredFailure derives Ord. |
| eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/Rules/SubGov.hs | DijkstraSubGovPredFailure derives Ord. |
| eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/Rules/SubDeleg.hs | DijkstraSubDelegPredFailure derives Ord. |
| eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/Rules/SubCerts.hs | Add Ord deriving for DijkstraSubCertsPredFailure. |
| eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/Rules/SubCert.hs | Add Ord deriving for DijkstraSubCertPredFailure. |
| eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/Rules/Mempool.hs | Add Ord deriving for DijkstraMempoolPredFailure. |
| eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/Rules/Ledger.hs | Add Ord deriving for DijkstraLedgerPredFailure. |
| eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/Rules/GovCert.hs | DijkstraGovCertPredFailure derives Ord. |
| eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/Rules/Gov.hs | DijkstraGovPredFailure derives Ord. |
| eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/Rules/Bbody.hs | Add Ord deriving for DijkstraBbodyPredFailure. |
| eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/BlockBody/Internal.hs | PerasCert derives Ord. |
| eras/conway/impl/src/Cardano/Ledger/Conway/TxInfo.hs | Add Ord deriving for ConwayContextError. |
| eras/conway/impl/src/Cardano/Ledger/Conway/Scripts.hs | Add Ord derivings for Conway plutus purpose wrappers. |
| eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Utxow.hs | Add Ord deriving for ConwayUtxowPredFailure. |
| eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Utxos.hs | Switch to CollectError and add Ord deriving for ConwayUtxosPredFailure. |
| eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Utxo.hs | Add Ord deriving for ConwayUtxoPredFailure. |
| eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Mempool.hs | Strengthen embedded predicate failure constraints from Eq to Ord. |
| eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Ledger.hs | Add Ord deriving for ConwayLedgerPredFailure. |
| eras/conway/impl/src/Cardano/Ledger/Conway/Rules/GovCert.hs | ConwayGovCertPredFailure derives Ord. |
| eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Gov.hs | ConwayGovPredFailure derives Ord. |
| eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Deleg.hs | ConwayDelegPredFailure derives Ord. |
| eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Certs.hs | Add Ord deriving for ConwayCertsPredFailure. |
| eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Cert.hs | Add Ord deriving for ConwayCertPredFailure. |
| eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Bbody.hs | Add Ord deriving for ConwayBbodyPredFailure. |
| eras/conway/impl/src/Cardano/Ledger/Conway/Governance/Procedures.hs | Add Ord derivings for voting procedure structures. |
| eras/byron/ledger/executable-spec/test/Test/Byron/Spec/Ledger/Update/Properties.hs | Predicate failure derives Ord for tests. |
| eras/byron/ledger/executable-spec/test/Test/Byron/Spec/Ledger/Delegation/Properties.hs | Predicate failure derives Ord for tests. |
| eras/byron/ledger/executable-spec/src/Byron/Spec/Ledger/Update.hs | Add Ord to multiple Byron predicate failure types. |
| eras/byron/ledger/executable-spec/src/Byron/Spec/Ledger/STS/UTXOWS.hs | Byron STS predicate failure derives Ord. |
| eras/byron/ledger/executable-spec/src/Byron/Spec/Ledger/STS/UTXOW.hs | Byron STS predicate failure derives Ord. |
| eras/byron/ledger/executable-spec/src/Byron/Spec/Ledger/STS/UTXO.hs | Byron STS predicate failure derives Ord. |
| eras/byron/ledger/executable-spec/src/Byron/Spec/Ledger/Delegation.hs | Add Ord to Byron delegation-related types and predicate failures. |
| eras/byron/chain/executable-spec/src/Byron/Spec/Chain/STS/Rule/SigCnt.hs | Byron chain predicate failure derives Ord. |
| eras/byron/chain/executable-spec/src/Byron/Spec/Chain/STS/Rule/Pbft.hs | Byron chain predicate failure derives Ord. |
| eras/byron/chain/executable-spec/src/Byron/Spec/Chain/STS/Rule/Epoch.hs | Byron chain predicate failure derives Ord. |
| eras/byron/chain/executable-spec/src/Byron/Spec/Chain/STS/Rule/Chain.hs | Byron chain predicate failure derives Ord. |
| eras/byron/chain/executable-spec/src/Byron/Spec/Chain/STS/Rule/Bupi.hs | Byron chain predicate failure derives Ord. |
| eras/byron/chain/executable-spec/src/Byron/Spec/Chain/STS/Rule/BBody.hs | Byron chain predicate failure derives Ord. |
| eras/byron/chain/executable-spec/src/Byron/Spec/Chain/STS/Block.hs | BlockHeader derives Ord. |
| eras/babbage/impl/src/Cardano/Ledger/Babbage/TxOut.hs | Add Ord deriving for BabbageTxOut. |
| eras/babbage/impl/src/Cardano/Ledger/Babbage/TxInfo.hs | Add Ord deriving for BabbageContextError. |
| eras/babbage/impl/src/Cardano/Ledger/Babbage/Rules/Utxow.hs | Add Ord deriving for BabbageUtxowPredFailure and strengthen embedded UTXOS failure to Ord. |
| eras/babbage/impl/src/Cardano/Ledger/Babbage/Rules/Utxos.hs | Strengthen PPUP failure constraint from Eq to Ord. |
| eras/babbage/impl/src/Cardano/Ledger/Babbage/Rules/Utxo.hs | Add Ord deriving for BabbageUtxoPredFailure. |
| eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxOut.hs | Add Ord for compact TxOut helpers and AlonzoTxOut. |
| eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Tx.hs | Add Ord for IsValid and adjust StAnnTx constraints to use CollectError. |
| eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Scripts.hs | Add Ord constraints/instances for Plutus purposes and AlonzoScript. |
| eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Utxow.hs | Add Ord deriving for AlonzoUtxowPredFailure. |
| eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Utxos.hs | Strengthen PPUP failure constraint to Ord, switch failure encoding to CollectError, and add Ord derivations for failures. |
| eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Utxo.hs | Add Ord deriving for AlonzoUtxoPredFailure. |
| eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Bbody.hs | Add Ord deriving for AlonzoBbodyPredFailure. |
| eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Plutus/TxInfo.hs | AlonzoContextError derives Ord. |
| eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Plutus/Context.hs | Require Ord (ContextError era) and add Ord for CollectError. |
| eras/allegra/impl/src/Cardano/Ledger/Allegra/Scripts.hs | Add Ord for timelock script types. |
| eras/allegra/impl/src/Cardano/Ledger/Allegra/Rules/Utxo.hs | Add Ord deriving for AllegraUtxoPredFailure and strengthen PPUP failure constraint to Ord. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
24edc78 to
f510bdb
Compare
|
The Hydra failure isn't spurious: if I build the test binary locally with nix and run it, it hangs at the start of the first test, just like the Hydra job. Perhaps the compiler bug is just popping up somewhere else, despite my workaround. |
|
It isn't just a Nix issue, either. |
3f879bb to
3f3b420
Compare
9da6432 to
320b650
Compare
|
There's still a problem with this: the tests hang/loop with ghc 9.8 but the option we're using to prevent this wasn't added until ghc 9.10. |
320b650 to
fe443c3
Compare
fe443c3 to
a75f5cc
Compare
|
As agreed with the team today, we'll discontinue supporting ghc 9.8. I've made the relevant components unbuildable with 9.8, and taken 9.8 out of the CI build matrix. |
| instance Ord MaryValue where | ||
| -- This is slightly inefficient, but pointwise requires (Integer -> Integer -> Bool) | ||
| x <= y = pointwise (<=) x y | ||
|
|
Description
We want to be able to have
Sets of predicate failures which requires them to haveOrdinstances.This also required changes to
cardano-base, because some types from base are embedded in some of our predicate failures, which requires those types to haveOrdinstances and currently they do not. (See IntersectMBO/cardano-base#658)We add the
Ordconstraint to theSTSclass to ensure that no predicate is missed.Checklist
CHANGELOG.mdfiles updated for packages with externally visible changes.NOTE: New section is never added with the code changes. (See RELEASING.md).
.cabalandCHANGELOG.mdfiles when necessary, according to theversioning process.
.cabalfiles updated when necessary.NOTE: If bounds change in a cabal file, that package itself must have a version increase. (See RELEASING.md).
scripts/fourmolize.sh).scripts/cabal-format.sh).scripts/gen-cddl.sh)hie.yamlupdated (usescripts/gen-hie.sh).