Skip to content

Commit

Permalink
docs: update MS4 report
Browse files Browse the repository at this point in the history
  • Loading branch information
euonymos committed Sep 3, 2024
2 parents 902fbb0 + d82da22 commit 93f0ba8
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ if ! has nix_direnv_version || ! nix_direnv_version 2.3.0; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc" "sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8="
fi
# https://github.com/input-output-hk/devx Slightly opinionated shared GitHub Action for Cardano-Haskell projects
use flake "github:input-output-hk/devx#ghc96-iog"
use flake "github:input-output-hk/devx?rev=6ee20d669c3a3823c5add1e1528818ccff1eb2b9#ghc96-iog"
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"Fracada",
"POCRE",
"Serialised"
]
],
"haskell.manageHLS": "PATH"
}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ Arch Linux has `libblst` in AUR, nix are exemplified by IOHK,
and manual installation is described here:
https://github.com/input-output-hk/cardano-node-wiki/blob/main/docs/getting-started/install.md#installing-blst

Make sure to `cabal update` before building.

The project uses `github:input-output-hk/devx` to make the development shell. See `.envrc` for details.

## Running tests

Tests are runned in emulated environment by default.
Expand Down
130 changes: 127 additions & 3 deletions docs/catalyst_milestone_reports.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ Changes:
([source](https://github.com/mlabs-haskell/cem-script/blob/master/src/Cardano/CEM/Monads/CLB.hs), usage examples are all unit tests)
* Running Quickcheck Dynamic tests, including mutation support
([source](https://github.com/mlabs-haskell/cem-script/blob/master/src/Cardano/CEM/Testing/StateMachine.hs),
[usage example](https://github.com/mlabs-haskell/cem-script/blob/master/test/Dynamic.hs))
[usage example](https://github.com/mlabs-haskell/cem-script/blob/master/test/Dynamic.hs),
[PR](https://github.com/mlabs-haskell/cem-script/pull/75) and [PR2](https://github.com/mlabs-haskell/cem-script/pull/89))
* Rendering CEMScript state graphs
([source](https://github.com/mlabs-haskell/cem-script/blob/master/src/Cardano/CEM/Documentation.hs), rendered example below)
([source](https://github.com/mlabs-haskell/cem-script/blob/master/src/Cardano/CEM/Documentation.hs), rendered example below,
[PR](https://github.com/mlabs-haskell/cem-script/pull/33))

## State graph examples

Expand All @@ -31,11 +33,133 @@ Winner -> "Void Out" [label="Buyout (stage Closed)"];
}
```

## Clarifications on M3 Deliverables

### Running an Emulated Environment by CLB

The CLB monad is designed to interact seamlessly with a Cardano mockchain environment. It can read from a shared environment, query blockchain parameters such as the current slot, and retrieve UTXO information, among other functions. This module facilitates simulation and testing, making it essential for unit tests and other testing scenarios where a controlled blockchain environment is needed. Using this emulated environment, developers can test and validate their Cardano applications in a reliable and repeatable manner.

### Running QuickCheck Dynamic Tests, Including Mutation Support

QuickCheck is a powerful Haskell library for property-based testing, which helps ensure that programs behave correctly for a wide range of inputs. The quickcheck-dynamic library extends this tool to stateful systems, making it particularly suitable for testing blockchain applications. Our testing framework uses a state machine model to simulate real-world scenarios, incorporating support for mutation testing. This approach helps verify that the system maintains correct behavior under various conditions, including edge cases and unexpected changes, thereby enhancing the robustness of the application.

### Rendering CEMScript State Graphs

Understanding state transitions and the overall system flow is critical for ensuring blockchain applications do not enter invalid states. To aid developers, we have implemented automated rendering of state graphs through our documentation module. This module generates DOT graph representations of CEMScript state transitions, providing an easy-to-understand visual model of how a DApp functions in real-world scenarios. This visualization tool increases developer confidence by highlighting the system's behavior and identifying potential shortcomings.

# Milestone 4

## Summary

Catalyst Milestone Outputs:

* Plutarch on-chain code generation and optimisation ([PR](https://github.com/mlabs-haskell/cem-script/pull/94))
* Static DSL for constraints and Plutarch on-chain code generation and optimisation ([PR#96](https://github.com/mlabs-haskell/cem-script/pull/96))
* Profiling implementation ([PR](https://github.com/mlabs-haskell/cem-script/pull/95))
* Profiling performed for old (using Plutus) and new (using Plutarch) code generator.
New one showed advantage over first one in all fees measured, and in some cases in order of magntude.
* A [video](https://drive.google.com/file/d/1720CsrdQFnpzA2ODDJuu6WK3thmEnE30/view?usp=sharing) that summarizes the outcomes achieved in the milestone.

## Profiling results

### Old (Plutus) backend ([implementation commit](https://github.com/mlabs-haskell/cem-script/tree/7e39ee5cbb8b512f873de05af3573bda1355d0aa))

Auction flow:

```
[ ( "BuyoutSpine"
, MkFees
{ fee = Coin 1072912
, usedMemory = 7642581
, usedCpu = 2334110505
}
)
, ( "CloseSpine"
, MkFees
{ fee = Coin 1240433
, usedMemory = 9509189
, usedCpu = 3008756651
}
)
, ( "CreateSpine"
, MkFees { fee = Coin 198369 , usedMemory = 0 , usedCpu = 0 }
)
, ( "MakeBidSpine"
, MkFees
{ fee = Coin 1240548
, usedMemory = 9489565
, usedCpu = 3001647940
}
)
, ( "StartSpine"
, MkFees
{ fee = Coin 1182093
, usedMemory = 8782473
, usedCpu = 2783614841
}
)
]
```

Voting flow (fails exceeding Tx limits on second vote):

```
[ ( "CreateSpine"
, MkFees { fee = Coin 190141 , usedMemory = 0 , usedCpu = 0 }
)
, ( "StartSpine"
, MkFees
{ fee = Coin 724655 , usedMemory = 2961157 , usedCpu = 943387589 }
)
, ( "VoteSpine"
, MkFees
{ fee = Coin 1164933
, usedMemory = 8369793
, usedCpu = 2680589904
}
)
]
```

### New (Plutarch with user-defined Plutus logic pieces) backend

Auction:

```
[ ( "BuyoutSpine"
, MkFees
{ fee = Coin 586779 , usedMemory = 625199 , usedCpu = 234106047 }
)
, ( "CloseSpine"
, MkFees
{ fee = Coin 667350 , usedMemory = 1358848 , usedCpu = 611301346 }
)
, ( "CreateSpine"
, MkFees { fee = Coin 198237 , usedMemory = 0 , usedCpu = 0 }
)
, ( "MakeBidSpine"
, MkFees
{ fee = Coin 669571 , usedMemory = 1364475 , usedCpu = 613191159 }
)
, ( "StartSpine"
, MkFees
{ fee = Coin 747648 , usedMemory = 2231662 , usedCpu = 1028952087 }
)
]
```

Voting Plutarch backend:

```
[ ( "CreateSpine"
, MkFees { fee = Coin 190009 , usedMemory = 0 , usedCpu = 0 }
)
, ( "StartSpine"
, MkFees
{ fee = Coin 495528 , usedMemory = 181513 , usedCpu = 72358787 }
)
, ( "VoteSpine"
, MkFees
{ fee = Coin 646247 , usedMemory = 1882546 , usedCpu = 760595491 }
)
]
```

0 comments on commit 93f0ba8

Please sign in to comment.