Skip to content

Overlapping Instance for PParamsUpdate #1049

@locallycompact

Description

@locallycompact

The change in cardano-api 10.18.0.0 to remove dependencies on cardano-ledger testing libraries is causing an overlapping instance error for us in hydra.


testlib/Test/Hydra/Tx/Gen.hs:348:32: error: [GHC-43085]
    • Overlapping instances for Arbitrary
                                  (cardano-ledger-core-1.17.0.0:Cardano.Ledger.Core.PParams.PParamsUpdate
                                     cardano-ledger-conway-1.19.0.0:Cardano.Ledger.Conway.Era.ConwayEra)
        arising from a use of ‘arbitrary’
      two instances involving out-of-scope types
        Matching instances:
          instance (cardano-ledger-core-1.17.0.0:Cardano.Ledger.Core.Era.Era
                      era,
                    Arbitrary
                      (cardano-ledger-core-1.17.0.0:Cardano.Ledger.Core.PParams.PParamsHKD
                         Ledger.StrictMaybe era)) =>
                   Arbitrary
                     (cardano-ledger-core-1.17.0.0:Cardano.Ledger.Core.PParams.PParamsUpdate
                        era)
          instance (cardano-ledger-core-1.17.0.0:Cardano.Ledger.Core.Era.Era
                      era,
                    Arbitrary
                      (cardano-ledger-core-1.17.0.0:Cardano.Ledger.Core.PParams.PParamsHKD
                         Ledger.StrictMaybe era)) =>
                   Arbitrary
                     (cardano-ledger-core-1.17.0.0:Cardano.Ledger.Core.PParams.PParamsUpdate
                        era)
    • In the second argument of ‘(<$>)’, namely ‘arbitrary’
      In the expression: fromLedgerTx <$> arbitrary
      In an equation for ‘arbitrary’:
          arbitrary = fromLedgerTx <$> arbitrary
    |
348 |   arbitrary = fromLedgerTx <$> arbitrary
    |                                ^^^^^^^^^

https://github.com/cardano-scaling/hydra/actions/runs/19962252260/job/57245260962#step:6:2269

As a result we are unable to upgrade cardano-api to 10.18. We rely on many instances from both projects. Removing one or the other testlib would force us to redefine the missing ones.

I wrote a policy on the hydra side to limit our consumption of upstream use of arbitrary in this issue: cardano-scaling/hydra#2351. This would insulate us from conflicting instances in the future were we to adopt this approach, however this is a huge task for us in the short term and so I am looking for other options to allow us to upgrade cardano-api in the meantime.

My first question is can the 10.18 change be reversed? Contrary to the ChangeLog entry it doesn't seem to me to be bad practice at all for cardano-api to rely on testlib code from cardano-ledger, as long as it is similarly scoped in a sublibrary away from production code. What was the justification here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions