Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
7ee51bb
doc ltl
mmontin Dec 21, 2025
8fb4fd8
this works !
mmontin Dec 27, 2025
db7c5cf
better ltlsimpl
mmontin Dec 29, 2025
82bed7d
laying out things nicely + commenting
mmontin Dec 29, 2025
e6b5cd5
perfecting the new ltl
mmontin Jan 3, 2026
b864fd1
final adjustements before diving into effects
mmontin Jan 3, 2026
0b29b87
back to booleans
mmontin Jan 3, 2026
f2419a2
all builtins at the same location
mmontin Jan 4, 2026
cfd30f7
before attempting effects
mmontin Jan 6, 2026
fac0044
cleaning up, adding proper type classes
mmontin Jan 8, 2026
77d6137
Requirment
mmontin Jan 8, 2026
49c7c59
minor cleanup
mmontin Jan 8, 2026
93015ee
laying out things in relevant files
mmontin Jan 8, 2026
e9b4626
fix haddock warnings
mmontin Jan 8, 2026
00bda78
comment updated
mmontin Jan 9, 2026
84efc2e
haddock rendering
mmontin Jan 9, 2026
9f692d8
restructuring and renaming combinators
mmontin Jan 9, 2026
faf0806
hm
mmontin Jan 11, 2026
94f605d
finished sketch
mmontin Jan 18, 2026
3f09a58
a more flexible version of handling tweaks
mmontin Jan 18, 2026
1dc7f29
moving families
mmontin Jan 19, 2026
7233b61
comments
mmontin Jan 19, 2026
bf73eea
comments
mmontin Jan 19, 2026
cdc88f9
running tweaks
mmontin Jan 19, 2026
6bcce61
Ltl
mmontin Jan 20, 2026
dea340a
no more Staged
mmontin Jan 20, 2026
5959cfd
ltl doc and exports
mmontin Jan 20, 2026
235513e
tweaks
mmontin Jan 20, 2026
e8ba4f6
datum hijacking
mmontin Jan 21, 2026
0a7d243
all effects spread around properly
mmontin Jan 22, 2026
b3fbf0c
removing old files
mmontin Jan 22, 2026
98d87e0
begin of autofillingé
mmontin Jan 22, 2026
f038ea9
GenerateTx
mmontin Jan 22, 2026
cf08230
more files transformed
mmontin Jan 22, 2026
7acfc4a
Only Testing and UtxoSearch remain
mmontin Jan 22, 2026
7971f23
pretty
mmontin Jan 22, 2026
37adaf5
starting Testing.hs
mmontin Jan 22, 2026
07d8971
main sources fully transformed
mmontin Jan 23, 2026
b9bf548
UtxoSearch
mmontin Jan 23, 2026
0cd2a41
StagedMockChain is back
mmontin Jan 23, 2026
52fc668
all but Spec.Ltl
mmontin Jan 24, 2026
723b998
fixing running
mmontin Jan 24, 2026
26c5bf6
progressing, but a lot of work remains in tests
mmontin Jan 24, 2026
42706ba
it finally compiles ... but it doesn't work ... yet
mmontin Jan 25, 2026
d40c963
MockChainState -> State
mmontin Jan 25, 2026
2406854
fixing bug in UTxOSearch
mmontin Jan 25, 2026
55b256a
fixing DH spec change
mmontin Jan 25, 2026
0ed2290
all good
mmontin Jan 25, 2026
299143f
improving pretty-printing of runs + note primitive
mmontin Jan 25, 2026
edde6ba
here comes MockChainJournal
mmontin Jan 25, 2026
c4de79e
migrating temporarily to the haskell-update branch from nixpkgs to ge…
mmontin Jan 25, 2026
995c205
tweak file in mockchain
mmontin Jan 26, 2026
679d118
Byebye UtxoState.hs
mmontin Jan 26, 2026
231bc34
optics utxoState
mmontin Jan 26, 2026
d397a78
Runnable + docs
mmontin Jan 26, 2026
22e7ad3
documentation
mmontin Jan 26, 2026
402f108
updating CHANGELOG from main
mmontin Jan 27, 2026
5612866
txSkelLabel -> txSkelLabels
mmontin Jan 27, 2026
82784eb
improvements
mmontin Jan 28, 2026
92b63f9
Merge branch 'main' into mm/effectful
mmontin Jan 28, 2026
6850bdc
ormolu
mmontin Jan 28, 2026
55be72d
assert + beginning of StagedRun
mmontin Jan 28, 2026
e3ff2fa
bye bye double nondet
mmontin Jan 29, 2026
ce1664d
bye InitialDistribution.hs
mmontin Jan 29, 2026
c3a5b8a
Inject + pretty
mmontin Jan 31, 2026
447600a
improving Staged instance
mmontin Feb 2, 2026
1ff0fce
more generic testing framework
mmontin Feb 2, 2026
1f1a923
improving the testing framework
mmontin Feb 2, 2026
efc2fbb
manual export of instances
mmontin Feb 2, 2026
e53fd35
merge + extraEffs
mmontin Feb 10, 2026
202443c
refactoring of initial distributions
mmontin Feb 11, 2026
556fe7c
some improvements here and there
mmontin Feb 13, 2026
e409f51
continuing the presentation
mmontin Feb 13, 2026
1df10c8
very slight adjustments
mmontin Feb 13, 2026
785f97f
without the demo
mmontin Feb 16, 2026
c93753e
fixing doc comments
mmontin Feb 16, 2026
76c1467
cherry-picking-v8-release
mmontin Jan 19, 2026
c5c0aba
cherry-picking-cne-chap-update
mmontin Feb 16, 2026
6027328
Create CODEOWNERS (#517)
mmontin Feb 16, 2026
76f454f
Merge branch 'main' into mm/effectful
mmontin Feb 19, 2026
1cd0b81
Merge branch 'main' into mm/effectful
mmontin Feb 19, 2026
f7fbd4d
reverting changelog
mmontin Feb 19, 2026
52b65e1
attempting another config
mmontin Feb 19, 2026
2295bf0
cabal file
mmontin Feb 19, 2026
643511f
beginning of changelog + cleanup packages
mmontin Feb 19, 2026
4161311
CHANGELOG
mmontin Feb 20, 2026
931175e
Updating the README
mmontin Feb 20, 2026
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
55 changes: 55 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,70 @@
expressiveness of the Tweak/Attack DSL.
- New `Ltl` combinators resulting from the addition of `LtlNot`, such as
`nowhere`, `whenAble`, ...
- `ExtendedStagedMockChain`: It is not possible to extend a mockchain run with
arbitrary effects, while the associated tweaks will also have access to the
added effects.
- A new capability in a mockchain run, which allows to take note (basically log)
anything. Functions `Note(|p|s|w|l)` support this functionality.
- A new capability in a mockchain run, which allows to make assertions which
will be displayed in the final result, and taken into account during
tests. Functions `assert(|')` support his functionality.
- A new `testBoolMsg` function which outputs an error message when given
`False`.
- Functions `testCookedFromInitDistTemplate` and
`testCookedQCFromInitDistTemplate` to build tests from the initial
distribution template (the old default initial distribution).
- The ability to enable/disable everything from the printing of the final result
of running a mockchain. The pretty printer has also been improved;
- The `HList` type for heterogeneous lists.

### Removed

- Tweaks can no longer issue write action such as waiting a certain amount of
time. As a consequence, `waitUntilValidTweak` has been removed.

### Changed

- The datum hijacking attack has been updated: all the sub-tweaks directly set
the new outputs, and they all return only the modified outputs.
- The module Ltl.Combinators has been integrated to Ltl. The combinators have
been enriched and renamed to better match the rest of the Ltl API.
- cooked-validators has been fully migrated from mtl to polysemy. Type class
`MonadBlockChain` and its variants have been replaced by `DirectMockChain`,
`StagedMockChain`, `ExtendedStagedMockChain` and `FullMockChain`.
- Some datum hijacking params have been changed. `ownedByDatumHijackingParams`
now takes a specific user as parameter, while its old behavior is now given by
`typedByDatumHijackingParams`. Also, `txSkelOutPredDatumHijackingParams` has
been renamed `outPredDatumHijackingParams`.
- The whole file tree has been updated, in particular under
`Cooked.MockChain`. Each effect is given its own file, such as
`Cooked.MockChain.Read`, `Cooked.MockChain.Error` ...
- Generation functions which use to live under
`Cooked.MockChain.GenerateTx.Witness` now live in their own
`Cooked.MockChain.GenerateTx.Credential` file.
- All the auto adjustment made by cooked are now implemented using tweaks, such
as autofilling of min ada, auto assignement of reference script...
- Initial distributions have been downgraded from a first class citizen to a
mere helping structure equivalent to using `forceOutputs`. By default, the
mockchain runs now have an empty state, and non-empty initial distribution can
be fed to runs in one of the following 3 ways: 1. use `forceOutputs` at the
beginning of a run. 2. Use `runMockChainFromConf` or
`runMockChainFromInitiDist` while running a trace. 3. use `withInitDist` when
running tests. The old default initial distribution still exists as
`initialDistributionTemplate` and is simply directly a list of outputs.
- The UTxO searches have been fully reworked. They now happen in 3
steps: 1. bootstrap the search with a set of UTxOs (`beginSearch` and
`beginSearchP`) 2. filter (`ensure`, `ensurePure`, `ensureAFoldIs` and
`ensureAFoldIsn't`) and/or extract elements from the selected outputs
(`extract`, `extractPure`,`extractAFold`, `extractTotal`, `extractPureTotal`
and `extractGetter`) in an type-retaining heterogeneous list. 2. retrieve the
result of the search (`getOutputs`, `getOutputsAndExtracts`, `getExtracts`,
`getTxOutRefs` and `getTxOutRefandOutputs`). Some additional helpers are
provided for basic searches (`utxosAtSearch`, `allUtxosSearch`,
`txSkelOutByRefSearch` and `txSkelOutByRefSearch'`) and for basic filters
(`ensureOnlyValueOutputs`, `ensureVanillaOutputs` and
`ensureProperReferenceScript`).
- `txSkelLabel` has been renamed `txSkelLabels`

### Fixed

Expand Down
206 changes: 139 additions & 67 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,38 @@ to [UPLC](https://plutonomicon.github.io/plutonomicon/uplc), such as

## How to integrate `cooked-validators` in a project

1. `cooked-validators` depends on
[cardano-haskell-packages](https://github.com/input-output-hk/cardano-haskell-packages)
to get cardano-related packages and on
[cardano-node-emulator](https://github.com/tweag/cardano-node-emulator-forked)
directly. If you have no constraint on the version of this package, copy the
file [`cabal.project`](./cabal.project) to your project and
[adapt](https://cabal.readthedocs.io/en/stable/cabal-project-description-file.html#specifying-the-local-packages)
the `packages` stanza.
There are two ways for this integration:

1. `cooked-validators`, and all its dependencies, are available on
[cardano-haskel-packages
(CHaP)](https://github.com/IntersectMBO/cardano-haskell-packages). To rely
on a release available there, add the following stanza to your
`cabal.project`:

```cabal.project
repository cardano-haskell-packages
url: https://chap.intersectmbo.org/
secure: True
root-keys:
3e0cce471cf09815f930210f7827266fd09045445d65923e6d0238a6cd15126f
443abb7fb497a134c343faf52f0b659bd7999bc06b7f63fa76dc99d631f9bea1
a86a1f6ce86c449c46666bda44268677abf29b5b2d2eb5ec7af903ec2f117a82
bcec67e8e99cabfa7764d75ad9b158d72bfacf70ca1d0ec8bc6b4406d1bf8413
c00aae8461a256275598500ea0e187588c35a5d5d7454fb57eac18d9edb86a56
d4a35cd3121aa00d18544bb0ac01c3e1691d618f462c46129271bccf39f7e8ee

index-state:
, cardano-haskell-packages 2026-02-13T00:00:02Z
```

2. Add the following stanza to the file `cabal.project`
To find the appropriate index state to fill above, look for
`cooked-validators` on [CHaP's packages
list](https://chap.intersectmbo.org/all-packages/).

2. Alternatively, if you want to rely on a specific commit or branch not
available on CHaP, you can import `cooked-validators` directly from GitHub
with the following stanza:

```cabal.project
source-repository-package
type: git
Expand All @@ -71,86 +93,136 @@ the `packages` stanza.
subdir:
.
```

where `myTag` is either a commit hash in the repo, or a tag, such as v8.0.0
(see [available
releases](https://github.com/tweag/cooked-validators/releases)).

Note that, should you do that, you would likely still need CHaP for all the
other dependencies.

3. Each release of `cooked-validators` is pinned to a specific version of
[`cardano-api`](https://github.com/IntersectMBO/cardano-api) which in turn
pins the versions of all other Cardano-related dependencies (including
Plutus). Make sure your project relies on the same version.
Each release of `cooked-validators` is pinned to a specific version of
[`cardano-api`](https://github.com/IntersectMBO/cardano-api) which in turn pins
the versions of all other Cardano-related dependencies (including Plutus). Make
sure your project relies on the same version.

## Example

This example shows how to create and validate a simple transaction that
transfers 10 Ada from wallet 1 to wallet 2, without manually handling fees or
balancing.
transfers 10 Ada from Alice (wallet 1) to Bob (wallet 2), without manually
handling fees or balancing.

1. Enter a Cabal read-eval-print-loop (with `cabal repl`)
1. Create a new Haskell module, for example `Demo.hs`

2. Import your required dependencies
``` haskell
> import Cooked
> import qualified Plutus.Script.Utils.Value as Script
import Cooked
import Plutus.Script.Utils.Value qualified as Script
```

3. Define a transaction which transfers 10 Ada from wallet 1 to wallet 2
3. Start the definition of a `MockChain` run:
``` haskell
myDemoRun :: StagedMockChain ()
myDemoRun = do
```

4. Define aliases for Alice and Bob:
``` haskell
let myTransaction = txSkelTemplate {txSkelOuts = [wallet 2 `receives` Value (Script.ada 10)], txSkelSignatories = txSkelSignatoriesFromList [wallet 1]}
alice <- define "Alice" $ wallet 1
bob <- define "Bob" $ wallet 2
```

5. Give some initial funds to Alice:
``` haskell
forceOutputs_ $ replicate 3 $ alice `receives` Value (Script.ada 10)
```

5. Take some notes:
``` haskell
noteS "Alice is sending 10 ADA to Bob"
noteS "I let cooked-validators do the heavy lifting for me"
```

4. Send the transaction for validation, and request the printing of the run
6. Submit the transaction:
``` haskell
printCooked . runMockChain . validateTxSkel_ $ myTransaction
validateTxSkel_
txSkelTemplate
{ txSkelOuts = [bob `receives` Value (Script.ada 10)],
txSkelSignatories = txSkelSignatoriesFromList [wallet 1]
}
```

5. Observe the log of the run, including:
- The original skeleton, and its balanced counterpart
- The associated fee and collaterals
- The final mockchain state, with every wallet's assets (notice the 10 ADA
payment owned by wallet 2)
- The value returned by the run (here `()` as we used `validateTxSkel_`)
```haskell
📖 MockChain run log:
⁍ New raw skeleton submitted to the adjustment pipeline:
- Validity interval: (-∞ , +∞)
- Signatories:
- wallet 1 [balancing]
- Outputs:
- Pays to pubkey wallet 2
- Lovelace: 10_000_000
⁍ New adjusted skeleton submitted for validation:
- Validity interval: (-∞ , +∞)
- Signatories:
- wallet 1 [balancing]
- Inputs:
- Spends #4480b35!3 from pubkey wallet 1
- Redeemer ()
- Lovelace: 100_000_000
- Outputs:
- Pays to pubkey wallet 2
- Lovelace: 10_000_000
- Pays to pubkey wallet 1
- Lovelace: 89_828_383
- Fee: Lovelace: 171_617
- No collateral required
⁍ New transaction successfully validated:
- Transaction id: #c095342
- Number of new outputs: 2
✅ UTxO state:
• pubkey wallet 1
- Lovelace: 89_828_383
- (×3) Lovelace: 100_000_000
• pubkey wallet 2
- Lovelace: 10_000_000
- (×4) Lovelace: 100_000_000
• pubkey wallet 3
- (×4) Lovelace: 100_000_000
• pubkey wallet 4
- (×4) Lovelace: 100_000_000
🟢 Returned value: ()
7. Lookup for the UTxOs now owned by Bob, and assert that he indeed possesses 1:
``` haskell
bobUtxos <- utxosAt bob
assert "Bob now has 1 utxo" $ length bobUtxos == 1
```

8. Enter a `cabal repl`, run and print the trace:
``` haskell
> printCooked $ runMockChainDef myDemoRun
```

5. Observe the output of printing the run, including:
- The notes you've taken
```
📔 Notes:
- Alice is going to send 10 ADA to Bob
- I let cooked-validators do the heavy lifting for me
```
- The log produced by cooked, with, the original submitted skeleton as well
as the adjusted and balanced skeletong with computed fee and collaterals.
```
📖 MockChain run log:
⁍ New raw skeleton submitted to the adjustment pipeline:
- Validity interval: (-∞ , +∞)
- Signatories:
- Alice [balancing]
- Outputs:
- Pays to pubkey Bob
- Lovelace: 10_000_000
⁍ New adjusted skeleton submitted for validation:
- Validity interval: (-∞ , +∞)
- Signatories:
- Alice [balancing]
- Inputs:
- Spends #d769532!1 from pubkey Alice
- Redeemer ()
- Lovelace: 10_000_000
- Spends #d769532!2 from pubkey Alice
- Redeemer ()
- Lovelace: 10_000_000
- Outputs:
- Pays to pubkey Bob
- Lovelace: 10_000_000
- Pays to pubkey Alice
- Lovelace: 9_826_799
- Fee: Lovelace: 173_201
- No collateral required
⁍ New transaction successfully validated:
- Transaction id: #bff7a56
- Number of new outputs: 2
```
- The assertions you've made and their evaluation.
```
✅ Assertions:
- ✔ Bob now has 1 utxo
```
- The final mockchain state, with every peer's assets (notice the 10 ADA
payment owned by Bob).
```
💰 UTxO state:
• pubkey Alice
- Lovelace: 9_826_799
- Lovelace: 10_000_000
• pubkey Bob
- Lovelace: 10_000_000
```
- The value returned by the run.
```
🟢 Success with returned value: ()
```

## Documentation

- The rendered Haddock for the current `main` branch can be found
Expand Down
3 changes: 1 addition & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,4 @@ package cardano-crypto-praos
flags: -external-libsodium-vrf

constraints:
, cardano-api == 10.18.1.0
, cardano-node-emulator == 1.4.1.0
, cardano-node-emulator == 1.4.1.0
Loading