IntersectMBO / plutus

The Plutus language implementation and tools
Apache License 2.0
1.56k stars 477 forks source link

Cannot apply two programs together #6455

Closed Fiftyw3bs closed 1 week ago

Fiftyw3bs commented 1 week ago

I'm not sure what is going on. I get the following while trying to build transaction.

 % ./start-app.sh
Writing Swagger file ...
parsing Config ...
Loading Providers ...
Starting server at 
 http://localhost:8222
[2024-09-10 09:00:25][GeniusYield.api-server][Debug][MacBook-Pro][PID 48652][ThreadId 49][tls-crdn-0.6.0-dbbfd75e:GeniusYield.TxBuilder.IO.Query src/GeniusYield/TxBuilder/IO/Query.hs:106:9] Querying UtxoRefs At Address: addr_test1...3km
[2024-09-10 09:00:25][GeniusYield.api-server.buildTxBody][Debug][MacBook-Pro][PID 48652][ThreadId 49][tls-crd[2024-09-10 09:00:25][GeniusYield.api-server][Debug][MacBook-Pro][PID 48652][ThreadId 49][tls-crdn-0.6.0-dbbfd75e:GeniusYield.TxBuilder.IO.Query src/GeniusYield/TxBuilder/IO/Query.hs:81:9] Querying utxos At Addresses: 
 [unsafeAddressFromText "addr_test1...3km"]
Cannot apply two programs together: the first program has version Version {_versionMajor = 1, _versionMinor = 1, _versionPatch = 0} but the second program has version Version {_versionMajor = 1, _versionMinor = 0, _versionPatch = 0}
CallStack (from HasCallStack):
  error, called at prelude/PlutusPrelude.hs:253:29 in plts-cr-1.30.0.0-b8c5ae45:PlutusPrelude

What does it mean to apply two programs together and how does one ensure the right ones are applied?

sourabhxyz commented 1 week ago

It appears that you compiled your program with PLC version 1.1.0 and later applied argument lifted with version 1.0.0. You may want to set target-version to 1.0.0 or lift with version 1.1.0...

Fiftyw3bs commented 1 week ago

I sincerely can't relate ;(

Here is how my cabal file looks:

myapp.cabal:

...

flag defer-plugin-errors
  description:
      Defer errors from the plugin, useful for things like Haddock that can't handle it.
  default: False
  manual: True

common myapp-common  
  default-language:   Haskell2010
  default-extensions:
    DataKinds
    DeriveAnyClass
    DerivingStrategies
    DerivingVia
    GADTs
    LambdaCase
    MultiWayIf
    OverloadedStrings
    RecordWildCards
    RoleAnnotations
    TemplateHaskell
    TypeFamilies
    UndecidableInstances
    UnicodeSyntax
    ViewPatterns
    DeriveGeneric
    NamedFieldPuns
    TypeOperators

  ghc-options:        -Wall

  build-depends:
    , aeson
    , base               <5
    , bytestring
    , file-embed
    , plutus-ledger-api
    , ply-core
    , text

  -- set target plutus-core version
  ghc-options: -fplugin-opt PlutusTx.Plugin:target-version=1.0.0
  -- so unfoldings are present even when compiled without optmizations
  ghc-options:
    -fno-ignore-interface-pragmas -fno-omit-interface-pragmas
    -Wno-partial-type-signatures

  -- expose all unfoldings, so plutustx compiler can do its job
  ghc-options:     -fexpose-all-unfoldings -fobject-code

library myapp-onchain
  import:          myapp-common
  exposed-modules:
    ...
  other-modules:

  hs-source-dirs:  onchain
  build-depends:
    , cardano-api
    , plutus-core
    , plutus-ledger-api
    , plutus-tx
    , aeson
    , serialise
    , plutus-tx-plugin
    -- , plutarch

library myapp-server-skeleton
  import:           myapp-common
  hs-source-dirs:   server-lib/MyApp
  exposed-modules:
    ...
  other-modules:
    ...

  build-depends:
    , base
    , aeson
    , myapp-onchain
    , atlas-cardano
    , swagger2
    , servant-server
    , containers
    , plutus-ledger-api
    , extra 

library myapp-server-lib
  import:           myapp-common
  hs-source-dirs:   server-lib/MyApp
  exposed-modules:
    ...
  other-modules:
    ...

  build-depends:
    , base
    , aeson
    , myapp-onchain
    , myapp-server-skeleton
    , atlas-cardano
    , swagger2
    , servant-server
    , servant-swagger
    , containers
    , text
    , lens
    , plutus-ledger-api
    , extra
    , validation

executable myapp-exe
  import:           myapp-common
  hs-source-dirs:   server
  main-is:          server-main.hs

  -- Modules included in this executable, other than Main.
  -- other-modules:

  -- LANGUAGE extensions used by modules in this package.
  -- other-extensions:
  hs-source-dirs:   app
  default-language: Haskell2010
  ghc-options:
    -O2 -threaded -rtsopts -with-rtsopts=-T -fplugin-opt
    PlutusTx.Plugin:defer-errors
  build-depends:
    , optparse-applicative
    , myapp-onchain
    , myapp-server-skeleton
    , myapp-server-lib
    , aeson-pretty
    , base
    , bytestring
    , atlas-cardano
    , servant-server
    , transformers
    , wai
    , wai-cors
    , http-types
    , warp
    -- , utilities

test-suite myapp-colony-tests
  import:         myapp-common
  ghc-options:    -threaded -rtsopts
  type:           exitcode-stdio-1.0
  main-is:        Colony/colony-tests.hs
  hs-source-dirs: tests
  other-modules:
    Colony.Tests.Utils
    Colony.Tests.CreateColony
    Colony.Tests.AddMember

  build-depends:
    , base
    , containers
    , myapp-onchain
    , myapp-server-skeleton
    , myapp-server-lib
    , atlas-cardano
    , mtl
    , plutus-simple-model
    , tasty
    , tasty-hunit

test-suite myapp-colony-privnet-tests
  import:         myapp-common
  type:           exitcode-stdio-1.0
  ghc-options:    -threaded -rtsopts
  hs-source-dirs: tests-privnet
  main-is:        Colony/colony-privnet-tests.hs
  other-modules:
    Colony.Tests.CreateColony
    Colony.Tests.Utils

  build-depends:
    , base
    , myapp-onchain
    , myapp-server-skeleton
    , myapp-server-lib
    , atlas-cardano
    , tasty
    , tasty-hunit
    -- , plutus-size-check
    , plutus-ledger-api
    , plutus-tx
    , plutus-tx-plugin

cabal.project:

repository cardano-haskell-packages
  url: https://input-output-hk.github.io/cardano-haskell-packages
  secure: True
  root-keys:
    3e0cce471cf09815f930210f7827266fd09045445d65923e6d0238a6cd15126f
    443abb7fb497a134c343faf52f0b659bd7999bc06b7f63fa76dc99d631f9bea1
    a86a1f6ce86c449c46666bda44268677abf29b5b2d2eb5ec7af903ec2f117a82
    bcec67e8e99cabfa7764d75ad9b158d72bfacf70ca1d0ec8bc6b4406d1bf8413
    c00aae8461a256275598500ea0e187588c35a5d5d7454fb57eac18d9edb86a56
    d4a35cd3121aa00d18544bb0ac01c3e1691d618f462c46129271bccf39f7e8ee

-- repeating the index-state for hackage to work around hackage.nix parsing limitation
index-state: 2024-08-27T16:28:01Z

index-state:
  , hackage.haskell.org 2024-08-27T16:28:01Z
  , cardano-haskell-packages 2024-07-24T14:16:32Z

packages:
    .
  , ./onchain/Utilities

package postgresql-libpq
  flags: +use-pkg-config

source-repository-package
  type: git
  location: https://github.com/geniusyield/ply
  tag: 4a61941b3287782d2c11f9ab1cae0889d0a57385
  --sha256: sha256-24WKaBs6qiJzi++wTyqIh61Dc1QeCzeo0YqLE4wsEbg=
  subdir: ply-core

source-repository-package
  type: git
  location: https://github.com/geniusyield/atlas
  tag: v0.6.0
  --sha256: sha256-v+tTCIz8uyaQfsMJRc5F36TNK9ZPfrBxwXLYaXqZrZA=

-------- Begin contents from @atlas@'s @cabal.project@ file. --------

package cardano-crypto-praos
  flags: -external-libsodium-vrf

source-repository-package
  type: git
  location: https://github.com/maestro-org/haskell-sdk
  tag: v1.7.2
  --sha256: sha256-nXnelHH4a+V0nguP8oUDlyEz/fLQ/i1fs/flyZTmvAc=

-- TODO: Temporary, until proposed changes are in upstream (track https://github.com/mlabs-haskell/clb/pull/44)
source-repository-package
  type: git
  location: https://github.com/sourabhxyz/clb
  tag: 09414a93047b4c7f6e03e20d1730c9c0f88e1d46
  --sha256: sha256-y5fF8IDywt/pQ3HsRE6CpAlqK4uiU/SRuDIqSHxBED0=

-- Obtaining cardano-node stuff for 9.1.0. These aren't published on CHaP yet.
source-repository-package
  type: git
  location: https://github.com/IntersectMBO/cardano-node
  tag: 9.1.0
  --sha256: sha256-F5wgRA820x16f+8c/LlEEBG0rMJIA1XWw6X0ZwX5UWs=
  subdir:
    cardano-node
    cardano-testnet
    trace-dispatcher

-- TODO: Make changes upstream
source-repository-package
  type: git
  location: https://github.com/geniusyield/cardano-wallet
  tag: 3413fdf74fd25b100662abf2a49c1afc892f1b79
  --sha256: sha256-V5DNUzraaDJo6cXc1eeVVIJNWqC8JayQrJeNNLg/Els=
  subdir:
    lib/address-derivation-discovery
    lib/balance-tx/
    lib/coin-selection/
    lib/crypto-primitives/
    lib/delta-store/
    lib/delta-table
    lib/delta-types/
    lib/iohk-monitoring-extra
    lib/launcher/
    lib/network-layer/
    lib/numeric/
    lib/primitive/
    lib/read
    lib/secrets
    lib/std-gen-seed/
    lib/test-utils/
    lib/text-class/
    lib/wai-middleware-logging/
    lib/wallet-benchmarks/
    lib/wallet/

------ Following is mostly from @cardano-wallet@'s @cabal.project@ file. -------

--------------------------------------------------------------------------------

source-repository-package
    type: git
    location: https://github.com/IntersectMBO/cardano-addresses
    tag: 2bca06deaa60e54a5322ac757387d744bf043367
    --sha256: 1y1mzfly7jac40b9g4xc078rcm5zqhc3xxv77kwxi10yph1jwq7z
    subdir: command-line
            core

-- Normally cabal won't apply ghc-options which we specify to build packages
-- to their "regular" dependencies.
-- However, the dependencies declared using the `source-repository-package`
-- pragma are an exception to this rule.
-- This is why we need to manually control options that are applied to the
-- `cardano-addresses` package by declaring them explicitly here.
--
-- Cardano Addresses CLI uses an outdated version of the `optparse-applicative`
-- library. This causes a deprecation warning to be emitted when building.
-- We don't want to promote this warning to an error level as it break the
-- release build and cardano-addresses codebase is not under our control.
package cardano-addresses-cli
    ghc-options:
        -Wwarn=deprecations

package cardano-addresses
    ghc-options:
        -Wwarn=incomplete-uni-patterns
-- END Cardano Addresses Dependency
--------------------------------------------------------------------------------

source-repository-package
    type: git
    location: https://github.com/input-output-hk/cardano-sl-x509
    tag: a91add165152fa36f08e95fafe7da24f1dba4690
    --sha256: 1ia8vlqghis92cla8qmqa6kh8f3jn29b01fshyk5hmgy5373s684

source-repository-package
    type: git
    location: https://github.com/cardano-foundation/cardano-wallet-client.git
    tag: 353412ca621dc28af53e4a19795338b19bab1b7b
    --sha256: 04q58c82wy6x9nkwqbvcxbv6s61fx08h5kf62sb511aqp08id4bb
    subdir: generated

--------------------------------------------------------------------------------
-- BEGIN Constraints tweaking section

allow-newer:
    async-timer:unliftio-core
  , servant-openapi3:*
  , katip:Win32
  , raven-haskell:aeson

constraints:
    base >= 4.18.2.0 && < 5
  , openapi3 >= 3.2.0
  , persistent ^>= 2.14.6.0
  , cardano-node ^>= 9.1.0
  , bech32 >= 1.1.7
  -- , postgresql-libpq >= 0.10

  -- lower versions of katip won't build with the Win32-2.12.0.1
  -- which is shipped with the ghc-9.2.8
  , katip >= 0.8.7.4

  -- Cardano Node dependencies:
  , io-classes >= 1.4
  , io-classes -asserts
  , ouroboros-consensus-cardano ^>= 0.18
  , ouroboros-network ^>= 0.16.1
  , ouroboros-network-protocols ^>= 0.9

-- END Constraints tweaking section
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
-- Flags for dependencies without an S-R-P pragma should be kept in this section
-- (conversely, flags for the S-R-P dependencies should be kept within the
-- same section where an S-R-P pragma is located,
-- for them to be managed together)

-- Using RDRAND instead of /dev/urandom as an entropy source for key
-- generation is dubious. Set the flag so we use /dev/urandom by default.
package cryptonite
  flags: -support_rdrand

package cardano-config
  flags: -systemd

package cardano-node
  flags: -systemd

package bitvec
   flags: -simd

-- -------------------------------------------------------------------------

-------- End contents from @cardano-wallet@'s @cabal.project@ file. --------
-------- End contents from @atlas@'s @cabal.project@ file. --------

No where else in my implementation have I had to explicitly specify a version.

Fiftyw3bs commented 1 week ago

I deleted my build directory and compiled the app again, and everything seems to work well now.

Thanks!