Skip to content

Commit

Permalink
From (plutus-apps, Babbage era, GHC 8 10 4) to (cardano-node-emulator…
Browse files Browse the repository at this point in the history
…, Conway era, GHC 9 6 3) (#388)

### Added
- File [IMPORTS](doc/IMPORTS.md) to specify how modules should be imported and prefixed
- Instaured a standard for naming imports, homogenized all modules accordingly
- Default language extensions in package.yaml
- A new set of tests `Cooked.BasicUsageSpec` to cover basic use cases
- A new validate function `validateTxSkel'` that directly returns a list of utxos
- A new typeclass `HasPubKeyHash` to allow payments to wallets directly instead of PKH
- An actual content to `hie.yaml` (automatically generated by `gen-hie`)
- Support for collaterals in skeleton options, with three options: auto from
  first signer, auto from given wallet, or given set of utxos.
- Top-level comments to all modules
- `currencySymbolFromLanguageAndMP` to get the right Currency symbol based on a
  plutus version and a minting policy
- `setParams` in `MonadBlockChainWithoutValidation` to account for future
  changes of parameters following votes.
- `txOptCollateralUtxos` to control which utxos should be used as collaterals
- Missing `Eq` instance for `MockChainError`
- Full support in `ShowBS` for printing into bytestring the whole transaction
  context within on-chain code
- `validatorToTypedValidator` which does what its name indicates
- Adding support for `PrettyCooked` for `TxLbl`

### Removed
- Extraneous dependencies in package.yaml
- File `Cooked.TestUtils`, its content has been added to `Cooked.MockChain.Testing`
- Support for importing scripts from bytestring in module Cooked.RawUPLC, to be
  added back later on
- Deprecated skeleton option: `txOptAwaitTxConfirmed`
- Deprecated use of `*` instead of `Type`
- Many unused pragmas
- Orphan default instance for `Ledger.Slot`
- `txOptBalancingUtxos` which was unused and mostly irrelevant

### Changed
- Default era from Babbage to Conway
- No longer rely on deprecated plutus-apps, but instead
  [cardano-node-emulator](https://github.com/IntersectMBO/cardano-node-emulator)
- From GHC 8.10.4 to 9.6.3
- Rely mostly on
  [CHaP](https://github.com/IntersectMBO/cardano-haskell-packages?tab=readme-ov-file)
  instead of direct git sources
- Update the cheatsheet to account for various small changes + collaterals
- `ImportQualifiedPost` by default
- `MockChainEnv` is gone, replaced by the new mcstParams field in `MockChainSt`
- The structure of the various steps around transaction validation (fee
  generation, ensuring min ada...)
- Regrouped all important validation steps, including modifications requested in
  skeleton options in the direct implementation of `validateTxSkel`.
- Homogenized and simplified the functions to generate transaction parts from a
  `TxSkel` by using a reader monad over various parameters.

### Fixed
- A bug where the ledger state would not be updated by consumed collaterals
- A curious choice where parameter changes for single transactions would be
  applied several times instead of one
- Various warnings around incomplete pattern matches when selecting utxos for
  balancing, with more suitable algorithms
  • Loading branch information
mmontin authored May 15, 2024
1 parent 77ffa1d commit 931d1b4
Show file tree
Hide file tree
Showing 69 changed files with 3,373 additions and 3,432 deletions.
98 changes: 78 additions & 20 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,65 @@
# Changelog

## Unreleased

### Added
- File [IMPORTS](doc/IMPORTS.md) to specify how modules should be imported and prefixed
- Instaured a standard for naming imports, homogenized all modules accordingly
- Default language extensions in package.yaml
- A new set of tests `Cooked.BasicUsageSpec` to cover basic use cases
- A new validate function `validateTxSkel'` that directly returns a list of utxos
- A new typeclass `HasPubKeyHash` to allow payments to wallets directly instead of PKH
- An actual content to `hie.yaml` (automatically generated by `gen-hie`)
- Support for collaterals in skeleton options, with three options: auto from
first signer, auto from given wallet, or given set of utxos.
- Top-level comments to all modules
- `currencySymbolFromLanguageAndMP` to get the right Currency symbol based on a
plutus version and a minting policy
- `setParams` in `MonadBlockChainWithoutValidation` to account for future
changes of parameters following votes.
- `txOptCollateralUtxos` to control which utxos should be used as collaterals
- Missing `Eq` instance for `MockChainError`
- Full support in `ShowBS` for printing into bytestring the whole transaction
context within on-chain code
- `validatorToTypedValidator` which does what its name indicates
- Adding support for `PrettyCooked` for `TxLbl`

### Removed
- Extraneous dependencies in package.yaml
- File `Cooked.TestUtils`, its content has been added to `Cooked.MockChain.Testing`
- Support for importing scripts from bytestring in module Cooked.RawUPLC, to be
added back later on
- Deprecated skeleton option: `txOptAwaitTxConfirmed`
- Deprecated use of `*` instead of `Type`
- Many unused pragmas
- Orphan default instance for `Ledger.Slot`
- `txOptBalancingUtxos` which was unused and mostly irrelevant

### Changed
- Default era from Babbage to Conway
- No longer rely on deprecated plutus-apps, but instead
[cardano-node-emulator](https://github.com/IntersectMBO/cardano-node-emulator)
- From GHC 8.10.4 to 9.6.3
- Rely mostly on
[CHaP](https://github.com/IntersectMBO/cardano-haskell-packages?tab=readme-ov-file)
instead of direct git sources
- Update the cheatsheet to account for various small changes + collaterals
- `ImportQualifiedPost` by default
- `MockChainEnv` is gone, replaced by the new mcstParams field in `MockChainSt`
- The structure of the various steps around transaction validation (fee
generation, ensuring min ada...)
- Regrouped all important validation steps, including modifications requested in
skeleton options in the direct implementation of `validateTxSkel`.
- Homogenized and simplified the functions to generate transaction parts from a
`TxSkel` by using a reader monad over various parameters.

### Fixed
- A bug where the ledger state would not be updated by consumed collaterals
- A curious choice where parameter changes for single transactions would be
applied several times instead of one
- Various warnings around incomplete pattern matches when selecting utxos for
balancing, with more suitable algorithms

## [[3.0.0]](https://github.com/tweag/cooked-validators/releases/tag/v3.0.0) - 2024-03-22

### Added
Expand Down Expand Up @@ -28,31 +88,30 @@
- A transaction option to choose which UTxOs can be spent for balancing
- Lenses for the fields of `TxOpts`
- [Cheatsheet](doc/CHEATSHEET.md)
- API now exposes: `Cooked.Tweak.ValidityRange`, `interpretAndRun`,
- API now exposes: `Cooked.Tweak.ValidityRange`, `interpretAndRun`,
`interpretAndRunWith`, `runTweak`, `runTweakFrom` and `datumHijackingTarget`
- `there` modifier to apply a tweak at a precise place in a trace
- New tweaks to change the start or end of the transaction validity range:
`setValidityStartTweak` and `setValidityEndTweak`
- UTxo searches with predicates over values, including only ada, or not only ada:
`filterWithValuePred`, `filterWithOnlyAda` and `filterWithNotOnlyAda`
- UTxo searches with predicates over values, including only ada, or not only
ada: `filterWithValuePred`, `filterWithOnlyAda` and `filterWithNotOnlyAda`
- New pretty-printing options related to hashes in `pcOptHashes` including the
possibility to assign human readable names to hashes (pubkeys, scripts,
minting policies)
- Initial distributions of funds can now include arbitrat payments
instead of only consisting of values belonging to wallets. In
particular, we can now initially pay to scripts and have utxos with
datums and reference scripts. We can still create an initial
distribution in the old fashion way with `distributionFromList` or
directly provide a list of payments with `InitialDistribution`.
- Dummy pre-existing validators in `Cooked.Validators` to be used for
testing purposes mainly but also as targets for attacks and tweaks.
- Small QOL helpers (`ada`, `lovelace` and `adaAssetClass`) to create
values in `Cooked.ValueUtils`.
- Initial distributions of funds can now include arbitrary payments instead of
only consisting of values belonging to wallets. In particular, we can now
initially pay to scripts and have utxos with datums and reference scripts. We
can still create an initial distribution in the old fashion way with
`distributionFromList` or directly provide a list of payments with
`InitialDistribution`.
- Dummy pre-existing validators in `Cooked.Validators` to be used for testing
purposes mainly but also as targets for attacks and tweaks.
- Small QOL helpers (`ada`, `lovelace` and `adaAssetClass`) to create values in
`Cooked.ValueUtils`.

### Removed

- `paysPKWithReferenceScript` (superseded by the `withReferenceScript`
modifier)
- `paysPKWithReferenceScript` (superseded by the `withReferenceScript` modifier)
- Do not export `Cooked.UtxoPayloadSet`

### Changed
Expand All @@ -66,9 +125,8 @@
distribution.

To update their code, users must
1. Adapt invokations of `Cooked.testFails` and `Cooked.testFailsFrom` adding
a predicate that must hold on the error returned by running the
transaction,
1. Adapt invokations of `Cooked.testFails` and `Cooked.testFailsFrom` adding a
predicate that must hold on the error returned by running the transaction,
2. Rename `Cooked.testFailsFrom'` into `Cooked.testFailsFrom`.
3. (Bonus) simplify, knowing that ``Cooked.testFailsFrom o x def ==
Cooked.testFails o x``
Expand Down Expand Up @@ -106,8 +164,8 @@ code quality.

- Transaction skeletons are now defined declaratively, no longer using lists of
constraints.
- Balancing and transaction generation no longer rely on `plutus-apps`, they
are performed entirely by cooked.
- Balancing and transaction generation no longer rely on `plutus-apps`, they are
performed entirely by cooked.
- Transaction skeletons need an explicit signer (no longer signed by a default
wallet).
- Modules have been reorganized in a flatter tree and cleaned up.
Expand Down
174 changes: 23 additions & 151 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,16 @@ package cardano-crypto-praos

source-repository-package
type: git
location: https://github.com/input-output-hk/plutus-apps.git
tag: 4578282f2f66c62a5f451701eca2f8f7d9d77c13
location: https://github.com/input-output-hk/cardano-node-emulator
-- This should follow the Conway branch until it is merged to main
tag: 1ad4cace0a8982c167f0c02ccf34a21931f2ce5f
subdir:
cardano-node-emulator
cardano-streaming
freer-extras
marconi-chain-index
marconi-core
pab-blockfrost
plutus-chain-index
plutus-chain-index-core
plutus-contract
plutus-ledger
plutus-script-utils
plutus-tx-constraints

-- Everything below this point has been copied from plutus-apps' cabal.project
freer-extras
-- Everything below this point has been copied from cardano-node-emulator cabal.project

-- Custom repository for cardano haskell packages
-- See https://github.com/input-output-hk/cardano-haskell-packages on how to use CHaP in a Haskell project.
Expand All @@ -41,13 +34,10 @@ repository cardano-haskell-packages
c00aae8461a256275598500ea0e187588c35a5d5d7454fb57eac18d9edb86a56
d4a35cd3121aa00d18544bb0ac01c3e1691d618f462c46129271bccf39f7e8ee

-- See CONTRIBUTING.adoc for how to update index-state
index-state: 2023-05-01T00:00:00Z

-- See CONTRIBUTING.adoc for how to update index-state
index-state:
, hackage.haskell.org 2023-05-01T00:00:00Z
, cardano-haskell-packages 2023-05-01T00:00:00Z
, hackage.haskell.org 2024-03-21T00:00:00Z
, cardano-haskell-packages 2024-03-21T00:00:00Z

-- We never, ever, want this.
write-ghc-environment-files: never
Expand All @@ -60,151 +50,33 @@ benchmarks: true
-- 'tasty' output.
test-show-details: direct

allow-newer:
-- cardano-ledger packages need aeson >2, the following packages have a
-- too restictive upper bounds on aeson, so we relax them here. The hackage
-- trustees can make a revision to these packages cabal file to solve the
-- issue permanently.
, ekg:aeson
, ekg-json:aeson
, openapi3:aeson
, servant:aeson
, servant-client-core:aeson
, servant-server:aeson
, servant-foreign:lens
, blockfrost-api:lens

constraints:
-- cardano-prelude-0.1.0.0 needs
, protolude <0.3.1

-- cardano-ledger-byron-0.1.0.0 needs
, cardano-binary <1.5.0.1

-- plutus-core-1.0.0.1 needs
, cardano-crypto-class >2.0.0.0
, algebraic-graphs <0.7

-- cardano-ledger-core-0.1.0.0 needs
, cardano-crypto-class <2.0.0.1

-- cardano-crypto-class-2.0.0.0.1 needs
, cardano-prelude <0.1.0.1

-- dbvar from cardano-wallet needs
, io-classes <0.3.0.0

-- newer typed-protocols need io-classes>=0.3.0.0 which is incompatible with dbvar's constraint above
, typed-protocols==0.1.0.0

, aeson >= 2

, hedgehog >= 1.1

-- ouroboros-consensus-shelley-0.1.0.1 needs
, ouroboros-consensus-protocol==0.1.0.1

-- The plugin will typically fail when producing Haddock documentation. However,
-- in this instance you can simply tell it to defer any errors to runtime (which
-- will never happen since you're building documentation).
--
-- So, any package using 'PlutusTx.compile' in the code for which you need to
-- generate haddock documentation should use the following 'haddock-options'.
package plutus-ledger
haddock-options: "--optghc=-fplugin-opt PlutusTx.Plugin:defer-errors"
package plutus-script-utils
haddock-options: "--optghc=-fplugin-opt PlutusTx.Plugin:defer-errors"
package plutus-contract
haddock-options: "--optghc=-fplugin-opt PlutusTx.Plugin:defer-errors"

-- These packages appear in our dependency tree and are very slow to build.
-- Empirically, turning off optimization shaves off ~50% build time.
-- It also mildly improves recompilation avoidance.
-- For dev work we don't care about performance so much, so this is okay.
package cardano-ledger-alonzo
optimization: False
package ouroboros-consensus-shelley
optimization: False
package ouroboros-consensus-cardano
optimization: False
package cardano-api
optimization: False
package cardano-wallet
optimization: False
package cardano-wallet-core
optimization: False
package cardano-wallet-cli
optimization: False
package cardano-wallet-launcher
optimization: False
package cardano-wallet-core-integration
optimization: False

-- Direct dependency.
-- Compared to others, cardano-wallet doesn't bump dependencies very often.
-- Making it a good place to start when bumping dependencies.
-- As, for example, bumping the node first highly risks breaking API with the wallet.
-- Unless early bug fixes are required, this is fine as the wallet tracks stable releases of the node.
-- And it is indeed nice for plutus-apps to track stable releases of the node too.
--
-- The current version is dated 2022/08/10
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-wallet
tag: 18a931648550246695c790578d4a55ee2f10463e
subdir:
lib/cli
lib/core
lib/core-integration
lib/dbvar
lib/launcher
lib/numeric
lib/shelley
lib/strict-non-empty-containers
lib/test-utils
lib/text-class
--sha256: 0i40hp1mdbljjcj4pn3n6zahblkb2jmpm8l4wnb36bya1pzf66fx
package cardano-crypto-praos
flags: -external-libsodium-vrf

-- Should follow cardano-wallet.
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-addresses
tag: b7273a5d3c21f1a003595ebf1e1f79c28cd72513
subdir:
-- cardano-addresses-cli
command-line
-- cardano-addresses
core
--sha256: 129r5kyiw10n2021bkdvnr270aiiwyq58h472d151ph0r7wpslgp
-- Haddock needs this to be able to build the documentation
package plutus-script-utils
haddock-options: "--optghc=-fplugin-opt PlutusTx.Plugin:defer-errors"
package plutus-ledger
haddock-options: "--optghc=-fplugin-opt PlutusTx.Plugin:defer-errors"

constraints:
cardano-api ^>= 8.42

-- This is needed because we rely on an unreleased feature
-- https://github.com/input-output-hk/cardano-ledger/pull/3111
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger
tag: da3e9ae10cf9ef0b805a046c84745f06643583c2
location: https://github.com/input-output-hk/quickcheck-contractmodel
tag: fdfbbfed09b48dada31bcb4e5b0e0e6d2cffba7f
--sha256: sha256-25BrEBetu35rAlNM+rZijjgS4cIG/Q4gcd5YYNqn2Vk=
subdir:
eras/alonzo/impl
eras/alonzo/test-suite
eras/babbage/impl
eras/babbage/test-suite
eras/byron/chain/executable-spec
eras/byron/crypto
eras/byron/crypto/test
eras/byron/ledger/executable-spec
eras/byron/ledger/impl
eras/byron/ledger/impl/test
eras/shelley/impl
eras/shelley/test-suite
eras/shelley-ma/impl
eras/shelley-ma/test-suite
libs/cardano-ledger-core
libs/cardano-ledger-pretty
libs/cardano-protocol-tpraos
libs/cardano-data
libs/vector-map
libs/set-algebra
libs/small-steps
libs/small-steps-test
libs/non-integral
--sha256: 1jg1h05gcms119mw7fz798xpj3hr5h426ga934vixmgf88m1jmfx
quickcheck-contractmodel
quickcheck-threatmodel
Loading

0 comments on commit 931d1b4

Please sign in to comment.