input-output-hk / typed-protocols

Session types framework with support of protocol pipelining.
15 stars 4 forks source link

When using Cardano Haskell package repository, typed-protocols fails to build. #21

Closed jonathangenlambda closed 1 year ago

jonathangenlambda commented 2 years ago

Describe the bug We are using the Cardano Haskell package repository to bring in the cardano-api-1.35.3 dependency. We followed the instructions as described in Cardano Haskell package repository but when building the project we encounter the following build error:

Preprocessing library for typed-protocols-0.1.0.1..
Building library for typed-protocols-0.1.0.1..
[1 of 6] Compiling Network.TypedProtocol.Core ( src/Network/TypedProtocol/Core.hs, dist/build/Network/TypedProtocol/Core.o, dist/build/Network/TypedProtocol/Core.dyn_o )
[2 of 6] Compiling Network.TypedProtocol.Pipelined ( src/Network/TypedProtocol/Pipelined.hs, dist/build/Network/TypedProtocol/Pipelined.o, dist/build/Network/TypedProtocol/Pipelined.dyn_o )
[3 of 6] Compiling Network.TypedProtocol.Driver ( src/Network/TypedProtocol/Driver.hs, dist/build/Network/TypedProtocol/Driver.o, dist/build/Network/TypedProtocol/Driver.dyn_o )

src/Network/TypedProtocol/Driver.hs:29:1: error:
    Could not find module `Control.Concurrent.Class.MonadSTM.TQueue'
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
29 | import           Control.Concurrent.Class.MonadSTM.TQueue
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cabal: Failed to build cardano-crypto-wrapper-1.3.0

Adding the io-classes repo as source-repository-package did not solve the issue.

To Reproduce Create a your-project.cabal file with cardano-api >= 1.35.3 as dependency, and a cabal.project file which contains the cardano-haskell-packages repository with the current date as index-state.

Expected behaviour Build should succeed.

Desktop (please complete the following information):

coot commented 2 years ago

You also need a newer version of io-sim package, io-sim >= 0.3

jonathangenlambda commented 2 years ago

Added this to the .cabal file, but now running into different problems:

...
[__4] next goal: ouroboros-network-framework (dependency of cardano-api)
[__4] rejecting: ouroboros-network-framework-0.1.0.1 (conflict:
io-classes==0.3.0.0, ouroboros-network-framework => io-classes>=0.1 && <0.3)
[__4] skipping: ouroboros-network-framework-0.1.0.0 (has the same
characteristics that caused the previous version to fail: excludes
'io-classes' version 0.3.0.0)
[__4] fail (backjumping, conflict set: cardano-api, io-classes,
ouroboros-network-framework)
...

When specifying io-sim without any version constraints I run into the same error as initially reported.

coot commented 2 years ago

Clearly I was wrong. It's probably the other way around, have you tried adding typed-protocols == 0.1.0.0 constraint?

jonathangenlambda commented 2 years ago

Now I am running into a different compiler error:

Configuring library for cardano-crypto-wrapper-1.3.0..
Preprocessing library for cardano-crypto-wrapper-1.3.0..
Building library for cardano-crypto-wrapper-1.3.0..
[ 1 of 21] Compiling Cardano.Crypto.Hashing ( src/Cardano/Crypto/Hashing.hs, dist/build/Cardano/Crypto/Hashing.o, dist/build/Cardano/Crypto/Hashing.dyn_o )

src/Cardano/Crypto/Hashing.hs:155:10: error:
    Not in scope: type constructor or class `HeapWords'
    |
155 | instance HeapWords (AbstractHash algo a) where
    |          ^^^^^^^^^

<no location info>: warning: [-Wunused-packages]
    The following packages were specified via -package or -package-id flags,
    but were not needed for compilation:
      - mtl-2.2.2
      - data-default-0.7.1.1
      - cardano-crypto-1.1.1
      - canonical-json-0.6.0.1
      - base64-bytestring-type-1.0.1
      - base64-bytestring-1.2.1.0

Failed to build plutus-core-1.0.0.1.
Build log (
/root/.cabal/logs/ghc-8.10.7/plutus-core-1.0.0.1-26e4a7bbfc9037151c0beac8a59cf5344c909e6cf77ba57fd2c6be95623ba966.log
):
Warning: plutus-core.cabal:309:31: visibility is experimental feature (issue
#5660)
Configuring library for plutus-core-1.0.0.1..
Preprocessing library for plutus-core-1.0.0.1..
Building library for plutus-core-1.0.0.1..
[  1 of 189] Compiling Data.Aeson.Flatten ( plutus-core/src/Data/Aeson/Flatten.hs, dist/build/Data/Aeson/Flatten.o, dist/build/Data/Aeson/Flatten.dyn_o )
...
...
...
[134 of 189] Compiling PlutusIR.Core.Plated ( plutus-ir/src/PlutusIR/Core/Plated.hs, dist/build/PlutusIR/Core/Plated.o, dist/build/PlutusIR/Core/Plated.dyn_o )

plutus-ir/src/PlutusIR/Core/Plated.hs:103:8: warning: [-Wname-shadowing]
    This binding for `<.*>' shadows the existing binding
      imported from `Data.Functor.Apply' at plutus-ir/src/PlutusIR/Core/Plated.hs:37:1-25
      (and originally defined in `Data.Functor.Bind.Class')
    |
103 |     ff <.*> MaybeApply (Left fa) = ff <.> fa
    |        ^^^^
[135 of 189] Compiling PlutusIR.Core.Instance.Pretty ( plutus-ir/src/PlutusIR/Core/Instance/Pretty.hs, dist/build/PlutusIR/Core/Instance/Pretty.o, dist/build/PlutusIR/Core/Instance/Pretty.dyn_o )
...
...
...
[171 of 189] Compiling PlutusIR.Transform.DeadCode ( plutus-ir/src/PlutusIR/Transform/DeadCode.hs, dist/build/PlutusIR/Transform/DeadCode.o, dist/build/PlutusIR/Transform/DeadCode.dyn_o )

plutus-ir/src/PlutusIR/Transform/DeadCode.hs:51:45: error:
    * Couldn't match expected type `T.ToVertex Deps.Node'
                  with actual type `G.Graph Deps.Node'
    * In the second argument of `T.reachable', namely `depGraph'
      In the second argument of `($)', namely
        `T.reachable Deps.Root depGraph'
      In the expression: Set.fromList $ T.reachable Deps.Root depGraph
   |
51 |     in Set.fromList $ T.reachable Deps.Root depGraph
   |                                             ^^^^^^^^

<no location info>: warning: [-Wunused-packages]
    The following packages were specified via -package or -package-id flags,
    but were not needed for compilation:
      - extra-1.7.12
      - dom-lt-0.2.3
cabal: Failed to build cardano-crypto-wrapper-1.3.0 (which is required by
coot commented 2 years ago

You need to check which version of plutus you need, you could peek at dist_newstyle/cache/plan.json in cardano-node repo at the version you are using.

We need to provide tigther bounds for the packages across our repos, we recently started to use CHaP and we still have some rough edges, but I am sure we will improve the state of affairs.

jonathangenlambda commented 1 year ago

Not sure what you mean by _peeking at distnewstyle/cache/plan.json in cardano-node repo at the version you are using.

It seems to me that the current state of CHaP is unusable even for simple use cases (just want to bring in cardano-api). Will therefore stick to source-repository-package which is also not ideal but works for now. Will try CHaP at a later time, maybe will then be improved.