Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate latest ledger dependencies #5013

Merged
merged 14 commits into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ logs

.vscode/

# Test artifacts
cardano-tracer/cardano-tracer-test

# IntellIJ project folder
.idea/

2 changes: 1 addition & 1 deletion bench/cardano-topology/cardano-topology.cabal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cabal-version: 3.0

name: cardano-topology
version: 1.36.0
version: 8.0.0
synopsis: A cardano topology generator
description: A cardano topology generator.
category: Cardano,
Expand Down
13 changes: 1 addition & 12 deletions bench/locli/src/Cardano/Analysis/API/Ground.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Cardano.Analysis.API.Ground
)
where

import Prelude (fail, show)
import Prelude (show)
import Cardano.Prelude hiding (head)
import Unsafe.Coerce qualified as Unsafe

Expand Down Expand Up @@ -96,17 +96,6 @@ newtype Host = Host { unHost :: ShortText }
deriving anyclass NFData
deriving Show via Quiet Host

instance FromJSON BlockNo where
parseJSON o = case o of
Number{} -> BlockNo <$> parseJSON o
Object o' -> BlockNo <$> o' .: "unBlockNo"
_ -> fail "illegal type for BlockNo"
-- FIXME: this workaround catches a faulty JSON serialisation of BlockNo
-- is: {"unBlockNo":1790}
-- should be: 1790
instance ToJSON BlockNo where
toJSON (BlockNo x) = toJSON x

newtype EpochSlot = EpochSlot { unEpochSlot :: Word64 }
deriving stock (Eq, Generic, Ord, Show)
deriving newtype (FromJSON, NFData, ToJSON, Num)
Expand Down
9 changes: 5 additions & 4 deletions bench/tx-generator/src/Cardano/Benchmarking/Script/Env.hs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ import Prelude
import Cardano.Benchmarking.GeneratorTx
import qualified Cardano.Benchmarking.LogTypes as Tracer
import Cardano.Benchmarking.OuroborosImports (NetworkId, PaymentKey, ShelleyGenesis,
SigningKey, StandardShelley)
SigningKey)
import Cardano.Benchmarking.Script.Types
import Cardano.Benchmarking.Wallet
import Cardano.Ledger.Crypto (StandardCrypto)
import Cardano.Node.Protocol.Types (SomeConsensusProtocol)
import Ouroboros.Network.NodeToClient (IOManager)

Expand All @@ -69,7 +70,7 @@ import Cardano.TxGenerator.Types (TxGenError (..))

data Env = Env { protoParams :: Maybe ProtocolParameterMode
, benchTracers :: Maybe Tracer.BenchTracers
, envGenesis :: Maybe (ShelleyGenesis StandardShelley)
, envGenesis :: Maybe (ShelleyGenesis StandardCrypto)
, envProtocol :: Maybe SomeConsensusProtocol
, envNetworkId :: Maybe NetworkId
, envSocketPath :: Maybe FilePath
Expand Down Expand Up @@ -125,7 +126,7 @@ setProtoParamMode val = modifyEnv (\e -> e { protoParams = pure val })
setBenchTracers :: Tracer.BenchTracers -> ActionM ()
setBenchTracers val = modifyEnv (\e -> e { benchTracers = pure val })

setEnvGenesis :: ShelleyGenesis StandardShelley -> ActionM ()
setEnvGenesis :: ShelleyGenesis StandardCrypto -> ActionM ()
setEnvGenesis val = modifyEnv (\e -> e { envGenesis = pure val })

setEnvKeys :: String -> SigningKey PaymentKey -> ActionM ()
Expand Down Expand Up @@ -168,7 +169,7 @@ getProtoParamMode = getEnvVal protoParams "ProtocolParameterMode"
getBenchTracers :: ActionM Tracer.BenchTracers
getBenchTracers = getEnvVal benchTracers "BenchTracers"

getEnvGenesis :: ActionM (ShelleyGenesis StandardShelley)
getEnvGenesis :: ActionM (ShelleyGenesis StandardCrypto)
getEnvGenesis = getEnvVal envGenesis "Genesis"

getEnvKeys :: String -> ActionM (SigningKey PaymentKey)
Expand Down
10 changes: 2 additions & 8 deletions bench/tx-generator/src/Cardano/TxGenerator/Setup/Plutus.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Cardano.TxGenerator.Setup.Plutus
where

import Data.Bifunctor (bimap)
import Data.Map.Strict as Map (lookup, toAscList)
import Data.Map.Strict as Map (lookup)

import Control.Monad.Trans.Except
import Control.Monad.Trans.Except.Extra
Expand Down Expand Up @@ -176,11 +176,5 @@ preExecutePlutusV2 protocolVersion_ (PlutusScript _ (PlutusScriptSerialised scri
, PlutusV2.txInfoRedeemers = PlutusV2.fromList []
}

-- The order of the output list is important, but:
-- * This way of flattening it is not guaranteed to always be correct.
-- * There is no way to ensure that the list remains in the correct order.
-- However, we're bound to the type `Cardano.Api.ProtocolParameters.CostModel` which
-- might be changed from a key-value map to something providing stronger guarantees.
flattenCostModel :: CostModel -> [Integer]
flattenCostModel (CostModel cm)
= snd <$> Map.toAscList cm
flattenCostModel (CostModel cm) = cm
5 changes: 2 additions & 3 deletions bench/tx-generator/src/Cardano/TxGenerator/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ import GHC.Natural
import Cardano.Api

import Cardano.Api.Shelley (ProtocolParameters)
import Cardano.Ledger.Crypto (StandardCrypto)
import qualified Cardano.Ledger.Shelley.API as Ledger (ShelleyGenesis)
import Ouroboros.Consensus.Shelley.Eras (StandardShelley)
-- import Cardano.Node.Protocol.Types (SomeConsensusProtocol)

import Cardano.TxGenerator.Fund (Fund)

-- convenience alias for use trhougout the API
type ShelleyGenesis = Ledger.ShelleyGenesis StandardShelley
type ShelleyGenesis = Ledger.ShelleyGenesis StandardCrypto

-- some type aliases to keep compatibility with code in Cardano.Benchmarking
type NumberOfInputsPerTx = Int
Expand Down
1 change: 1 addition & 0 deletions bench/tx-generator/tx-generator.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ library
, cardano-git-rev
, cardano-ledger-alonzo
, cardano-ledger-byron
, cardano-ledger-core
, cardano-node
, cardano-prelude
, contra-tracer
Expand Down
7 changes: 5 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ repository cardano-haskell-packages
-- See CONTRIBUTING for information about these, including some Nix commands
-- you need to run if you change them
index-state:
, hackage.haskell.org 2023-03-30T00:00:00Z
, cardano-haskell-packages 2023-04-01T00:00:00Z
, hackage.haskell.org 2023-04-11T00:00:00Z
, cardano-haskell-packages 2023-04-13T17:16:53Z

packages:
cardano-api
Expand Down Expand Up @@ -80,6 +80,9 @@ tests: True

test-show-details: direct

-- Always write GHC env files, because they are needed for ghci.
write-ghc-environment-files: always

package snap-server
flags: +openssl

Expand Down
45 changes: 44 additions & 1 deletion cardano-api/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
`TestEnableDevelopmentNetworkProtocols` to `ExperimentalProtocolsEnabled`
([PR 4341](https://github.com/input-output-hk/cardano-node/pull/4341))

- Changed type of `protocolParamTxFeeFixed`, `protocolParamTxFeePerByte` from `Natural` to
`Lovelace` and `protocolUpdateTxFeeFixed` and `protocolUpdateTxFeePerByte` from `Maybe
Natural` to `Maybe Lovelace` ([PR 5013](https://github.com/input-output-hk/cardano-node/pull/5013))

- Append, not prepend change output when balancing a transaction ([PR 4343](https://github.com/input-output-hk/cardano-node/pull/4343))

- Expose convenience functions `executeQueryCardanoMode`, `determineEra`, `constructBalancedTx` and `queryStateForBalancedTx` ([PR 4446](https://github.com/input-output-hk/cardano-node/pull/4446))
Expand All @@ -30,7 +34,7 @@

- **Breaking change** - `queryExpr` to return `IO (Either UnsupportedNtcVersionError a)` instead of `IO a`.
([PR4788](https://github.com/input-output-hk/cardano-node/pull/4788))

- **Breaking change** - Remove distinction between multisig and timelock scripts([PR4763](https://github.com/input-output-hk/cardano-node/pull/4763))

- **Breaking change** Change return type of `queryNodeLocalState` to new `AcquiringFailure` type.
Expand All @@ -42,6 +46,45 @@

- Auto-balance multi asset transactions ([PR 4450](https://github.com/input-output-hk/cardano-node/pull/4450))

- **Breaking change** - Removed `fromShelleyPParams` in favor of
`fromLedgerPParams ShelleyBasedEraShelley`
([PR 5013](https://github.com/input-output-hk/cardano-node/pull/5013))

- **Breaking change** - JSON fields have been changed: ([PR 5013](https://github.com/input-output-hk/cardano-node/pull/5013))
- For `PState`:
- Renamed `"pParams pState"` -> `"pParams"`
- Renamed `"fPParams pState"` -> `"fPParams"`
- Renamed `"retiring pState"` -> `"retiring"`
- Added `"deposits"`
- For `DState`:
- Removed `"unifiedRewards"`
- Added `"unified"`, which contains an object with both rewards and deposits.
- For `InstantaneousRewards`:
- Addition of `"deltaReserves"` and `"deltaTreasury"` fields
- `CostModel` in `AlonzoGenesis` and `PParams` is formatted with a list of values to
promote forward compatibility

- Fix a bug where only metadata from TxAuxData was hashed upon
transaction body creation with `createTransactionBody` ([PR 5013](https://github.com/input-output-hk/cardano-node/pull/5013))

- **Breaking change** - Change representation of `CostModel`. It is no longer a mapping from
param name to values, but instead a list with values, where order of value dictates the
mapping to param names of a plutus cost model for a particular plutus version ([PR
5013](https://github.com/input-output-hk/cardano-node/pull/5013))

- **Breaking change** - ToJSON instance for CostModel and consequently for
ProtocolParameters will now produce a list of values instead of a key value
mapping. ([PR 5013](https://github.com/input-output-hk/cardano-node/pull/5013))

- Fix minUTxO calculation in `calculateMinimumUTxO` function in `cardano-api`
([PR 5013](https://github.com/input-output-hk/cardano-node/pull/5013))

- **Breaking change** - `calculateMinimumUTxO` no longer fails, it is a total computation.
lehins marked this conversation as resolved.
Show resolved Hide resolved
([PR 5013](https://github.com/input-output-hk/cardano-node/pull/5013))

- New generators in `gen` sublibrary: `genPositiveLovelace`, `genPositiveQuantity` and
`genSignedNonZeroQuantity`. ([PR 5013](https://github.com/input-output-hk/cardano-node/pull/5013))

### Bugs

- Allow reading text envelopes from pipes ([PR 4384](https://github.com/input-output-hk/cardano-node/pull/4384))
Expand Down
67 changes: 34 additions & 33 deletions cardano-api/cardano-api.cabal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cabal-version: 3.0

name: cardano-api
version: 1.36.0
version: 8.0.0
synopsis: The cardano api
description: The cardano api.
category: Cardano,
Expand Down Expand Up @@ -109,27 +109,29 @@ library

build-depends: aeson >= 1.5.6.0
, aeson-pretty >= 0.8.5
, array
, attoparsec
, base16-bytestring >= 1.0
, base58-bytestring
, bech32 >= 1.1.0
, bytestring
, cardano-binary
, cardano-crypto
, cardano-crypto-class ^>= 2.0
, cardano-crypto-wrapper ^>= 1.4
, cardano-data ^>= 0.1
, cardano-ledger-alonzo ^>= 0.1
, cardano-ledger-babbage ^>= 0.1
, cardano-ledger-byron ^>= 0.1
, cardano-ledger-conway
, cardano-ledger-core ^>= 0.1
, cardano-ledger-shelley ^>= 0.1
, cardano-ledger-shelley-ma ^>= 0.1
, cardano-protocol-tpraos >= 0.1
, cardano-crypto-class ^>= 2.1
, cardano-crypto-wrapper ^>= 1.5
, cardano-data >= 1.0
, cardano-ledger-alonzo >= 1.1
, cardano-ledger-allegra >= 1.1
, cardano-ledger-api >= 1.1
, cardano-ledger-babbage >= 1.1
, cardano-ledger-binary >= 1.1
, cardano-ledger-byron >= 1.0
, cardano-ledger-conway >= 1.1
, cardano-ledger-core >= 1.1
, cardano-ledger-mary >= 1.1
, cardano-ledger-shelley >= 1.1
, cardano-protocol-tpraos >= 1.0.1
, cardano-slotting >= 0.1
, cardano-strict-containers ^>= 0.1
, cardano-strict-containers >= 0.1
, cborg
, containers
, contra-tracer
Expand Down Expand Up @@ -163,7 +165,7 @@ library
, random
, scientific
, serialise
, small-steps ^>= 0.1
, small-steps ^>= 1.0
, stm
, text
, time
Expand All @@ -172,7 +174,6 @@ library
, typed-protocols ^>= 0.1
, unordered-containers >= 0.2.11
, vector
, vector-map ^>= 0.1
, yaml

library gen
Expand All @@ -193,14 +194,14 @@ library gen
, base16-bytestring
, bytestring
, cardano-api
, cardano-binary
, cardano-crypto-class ^>= 2.0
, cardano-crypto-test ^>= 1.4
, cardano-ledger-alonzo ^>= 0.1
, cardano-ledger-alonzo-test ^>= 0.1
, cardano-ledger-byron-test ^>= 1.4
, cardano-ledger-core ^>= 0.1
, cardano-ledger-shelley ^>= 0.1
, cardano-binary >= 1.6 && < 1.8
, cardano-crypto-class ^>= 2.1
, cardano-crypto-test ^>= 1.5
, cardano-ledger-alonzo >= 1.1
, cardano-ledger-alonzo-test
, cardano-ledger-byron-test >= 1.5
, cardano-ledger-core >= 1.1
, cardano-ledger-shelley >= 1.1
, containers
, hedgehog
, hedgehog-extras
Expand All @@ -217,20 +218,20 @@ test-suite cardano-api-test
, cardano-api
, cardano-api:gen
, cardano-crypto
, cardano-crypto-class ^>= 2.0
, cardano-crypto-test ^>= 1.4
, cardano-crypto-tests ^>= 2.0
, cardano-data ^>= 0.1
, cardano-ledger-alonzo ^>= 0.1
, cardano-ledger-core ^>= 0.1
, cardano-ledger-shelley ^>= 0.1
, cardano-ledger-shelley-test ^>= 0.1
, cardano-crypto-class ^>= 2.1
, cardano-crypto-test ^>= 1.5
, cardano-crypto-tests ^>= 2.1
, cardano-data >= 1.0
, cardano-ledger-api >= 1.1
, cardano-ledger-core:{cardano-ledger-core, testlib} >= 1.1
, cardano-ledger-shelley-test >= 1.1
, cardano-slotting ^>= 0.1
, containers
, hedgehog
, hedgehog-extras ^>= 0.4
, hedgehog-quickcheck
, mtl
, ouroboros-consensus
, microlens
, ouroboros-consensus-shelley
, QuickCheck
, tasty
Expand Down
Loading