Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
2628d1c
Make placeholders for Oura tests
Renegatto Aug 3, 2024
9e3ace0
Add oura and fourmolu to the dev shell
Renegatto Aug 5, 2024
3ebdcee
Prepare oura config
Renegatto Aug 6, 2024
ac8da62
Make tooling for running and sending data to oura
Renegatto Aug 6, 2024
5b7df39
Make tooling for receiving data from oura
Renegatto Aug 7, 2024
56e2d1d
Format Oura.hs
Renegatto Aug 7, 2024
003dd6f
Implement withNewFile util
Renegatto Aug 7, 2024
168e95f
Make oura daemon config constructor
Renegatto Aug 7, 2024
45e3975
Use types paths
Renegatto Aug 7, 2024
47103ab
Close temp file handle immediately
Renegatto Aug 7, 2024
e461f4e
Implement runOura
Renegatto Aug 7, 2024
af148a1
Rename Oura to Oura.Communication
Renegatto Aug 7, 2024
222c605
Rename Oura.Run to Oura
Renegatto Aug 7, 2024
28b7e46
Format code
Renegatto Aug 7, 2024
8860cef
Stop listening on oura shut down
Renegatto Aug 7, 2024
7b64aaa
Implement debug and clearLogs
Renegatto Aug 21, 2024
d1ffacf
Implement janitor
Renegatto Aug 21, 2024
1f5221e
Remove exampleTx from Oura.Communication
Renegatto Aug 21, 2024
dd72448
Make Oura working
Renegatto Aug 21, 2024
2bff8c1
Test that Oura is functioning
Renegatto Aug 21, 2024
6557aaf
Update tests entrypoint
Renegatto Aug 21, 2024
eed804f
Depend on 'async', enable threading
Renegatto Aug 21, 2024
e1bfffb
Rename first oura test
Renegatto Aug 22, 2024
cab2592
Make a separate dir for mocks
Renegatto Aug 22, 2024
fffde34
Create placeholders for AuctionExample oura tests
Renegatto Aug 22, 2024
0134438
Rename TxFanConstraint into TxFansConstraint, document code
Renegatto Aug 22, 2024
04f7bd9
Make identifiers them more descriptive
Renegatto Sep 3, 2024
0803787
Remove newtype as it can't be compiled by Plutus
Renegatto Sep 5, 2024
c7d664a
Make test placeholder
Renegatto Sep 5, 2024
dbb9285
Make type for a mock oura data
Renegatto Sep 5, 2024
0c4f8ec
Express existing mocks on haskell
Renegatto Sep 5, 2024
13fd381
De/serialize plutus addresses
Renegatto Sep 10, 2024
36d09c3
Create auction mock Tx WIP
Renegatto Sep 10, 2024
3be398a
Debug utxoRPC encoding
Renegatto Sep 12, 2024
177accd
Test that utxoRPC plutus data encoding is accepted by oura
Renegatto Sep 12, 2024
750da78
Format tests via fourmolu
Renegatto Sep 12, 2024
b3c92d3
Debug utxoRPC PlutusData.Bytes encoding
Renegatto Sep 12, 2024
07d53bb
Distinct between 28B and 32B blake2b hashes
Renegatto Sep 12, 2024
9b3486c
Format
Renegatto Sep 12, 2024
a936067
Use BS instead of Text; Encode hash as base16 hex instead of UTF8
Renegatto Sep 12, 2024
a2cf4b7
Move serialization logic to Mock.hs
Renegatto Sep 12, 2024
a1000c5
Clean up
Renegatto Sep 13, 2024
193b357
Set timeouts on the oura tests
Renegatto Sep 13, 2024
7a3dd8d
WIP: Make simple indexer test
Renegatto Sep 14, 2024
38f5c2c
Finish test
Renegatto Sep 14, 2024
bf3a4d6
Make lenses for Toml to edit oura config
Renegatto Sep 14, 2024
7d4983b
Use custom configs in oura tests
Renegatto Sep 15, 2024
7494b28
Remove Tx transition indexer tests
Renegatto Sep 16, 2024
deed8b7
Separate conversion between plutus and cardano from serialization
Renegatto Sep 16, 2024
fdcb9c9
Make extra prisms for oura configs
Renegatto Sep 16, 2024
b203fbc
Make test work with matching stake credntial
Renegatto Sep 16, 2024
2464e77
Implement OuraConfig generator
Renegatto Sep 16, 2024
8928b4f
Move OuraConfig gen out from tests
Renegatto Sep 16, 2024
5e7484e
Update oura to obtain a bugfix for filtering by payment key
Renegatto Sep 16, 2024
58f37bc
Format code
Renegatto Sep 16, 2024
2e80272
Adopt new oura
Renegatto Sep 16, 2024
e4ab8a8
Test that indexer ignores staking credential
Renegatto Sep 16, 2024
02f28fb
Resolve nix develop error
Renegatto Sep 16, 2024
ae30268
Move CEMScript to oura config functionality in CEM.OuraConfig
Renegatto Sep 16, 2024
481a7a9
Merge pull request #100 from mlabs-haskell/alexey/test-oura-filters-a…
euonymos Nov 27, 2024
16850b3
chore: reformat
Nov 27, 2024
e407192
chore: move Stage into CEM, comments in CEM
Nov 27, 2024
4a648d9
fix: keep ./tmp folder as it's needed for indexing tests
Nov 27, 2024
3af9d69
feat: add flag to run indexing tests
Nov 28, 2024
baee6d0
add flag to run indexing tests
Nov 28, 2024
e3c5c63
feat: parse transition spines from transactions WIP
Nov 30, 2024
3d7e90a
feat: return txs on submission WIP
Dec 2, 2024
f25405b
feat: build/parse Oura txs
Dec 4, 2024
b9f25e3
feat: transition tests for Auction example
Dec 5, 2024
4576977
chore: add ghc options that prevents ci crashes
Dec 5, 2024
2a866fd
chore: reorganize modules
Dec 5, 2024
92c7301
chore: clean up the code
Dec 6, 2024
c08a64d
Merge pull request #109 from mlabs-haskell/euonymos/final-clean-up
euonymos Dec 9, 2024
a83073b
Merge pull request #106 from mlabs-haskell/euonymos/rip-transition-spine
euonymos Dec 9, 2024
e684316
Merge branch 'master' into alexey/test-oura-filters
Dec 10, 2024
1c33ead
chore: reformat the code
Dec 10, 2024
feb2b05
feat: backport transitionStage
Dec 10, 2024
615dfd6
chore: format cabal file
Dec 10, 2024
74f8a3d
chore: redundant imports
Dec 10, 2024
e2407a0
chore: clean-up WIP
Dec 10, 2024
7ae5579
chore: code cleanup take #1 WIP
Dec 13, 2024
dbb5ce9
feat: newtype for SameScript agument
Dec 13, 2024
cb6d91b
chore: module reorganizing
Dec 13, 2024
9b8f93a
chore: remove redundant transitionStage
Dec 13, 2024
d592932
chore: remove dead code
Dec 13, 2024
40b4c11
feat: smart constructors for DSL
Dec 13, 2024
e15ae64
chore: rename perTransitionScriptSpec
Dec 13, 2024
8f80353
chore: refactor compile module
Dec 16, 2024
a352f62
chore: CEM.Indexing module
Dec 16, 2024
0b866c9
chore: refactor Cardano.CEM.Compile module
Dec 16, 2024
d3c479a
chore: remove broken CTxInfo
Dec 16, 2024
d49b06e
chore: renames and export in DSL module
Dec 16, 2024
3774144
chore: check all FIXME items
Dec 16, 2024
6fece23
fix: dynamic test is green, but without mutations
Dec 17, 2024
836389a
feat: rethink negative mutations
Dec 19, 2024
7e5058f
Merge remote-tracking branch 'origin/master' into euonymos/dynamic-test
Dec 19, 2024
8ce26d6
chore: fix imports and comments
Dec 19, 2024
79fc3b6
chore: cosmetics
Jan 17, 2025
713fc36
Merge pull request #113 from mlabs-haskell/euonymos/dynamic-test
euonymos Jan 17, 2025
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
2 changes: 1 addition & 1 deletion .ghcid
Original file line number Diff line number Diff line change
@@ -1 +1 @@
--command="cabal repl test-suite:cem-sdk-test" -W -T ":main"
--command="cabal repl test-suite:cem-script-test" -W -T ":main"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ haddocks
# Functions changed by runing local testnet
devnet/db
devnet/genesis-*.json
test.log
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.PHONY: run-oura-daemon

clear-sockets:
@rm ./oura-daemon-cursor || true
@rm ./oura-listening.socket || true
@rm ./own.socket || true

run-oura-daemon:
@clear-sockets || true
@oura daemon --config ./test/daemon.toml

format:
fourmolu --mode inplace $$(git ls-files '*.hs')
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ source-repository-package
tag: d5b0e7ce07258482d53704ce19383013b1fa6610
--sha256: 6+Os/mQDzBOU+TkTD+n/T1MFcI+Mn0/tcBMJhLRfqyA=

-- FIXME: Cannot use new commit, because it requires `plutus-ledger-api==1.29`
-- Cannot use new commit, because it requires `plutus-ledger-api==1.29`
source-repository-package
type: git
location: https://github.com/Plutonomicon/plutarch-plutus
Expand Down
105 changes: 76 additions & 29 deletions cem-script.cabal
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
cabal-version: 3.8
name: cem-script
version: 0.1.0
synopsis: Cardano DApp SDK
homepage: https://github.com/cem-script
synopsis: CEM Script - a Cardano dApp SDK
homepage: https://github.com/mlabs-haskell/cem-script
author: MLabs
maintainer: gregory@mlabs.city
maintainer: ilia@mlabs.city
data-files: README.md
tested-with: GHC ==9.6.3

Expand All @@ -15,9 +15,11 @@ flag dev
default: True
manual: False

common common-lang
-- Options from MLabs styleguide
flag force-recomp
description: Compile with -fforce-recomp and -Wunused-packages
default: False

common common-lang
ghc-options:
-Wall -Wcompat -Wincomplete-record-updates
-Wincomplete-uni-patterns -Wredundant-constraints
Expand All @@ -26,9 +28,16 @@ common common-lang
if !flag(dev)
ghc-options: -Werror

if flag(dev)
default-extensions: PartialTypeSignatures

if flag(force-recomp)
ghc-options: -fforce-recomp -Wunused-packages

build-depends:
, base
, containers
, extra
, mtl
, transformers

Expand All @@ -54,9 +63,6 @@ common common-lang
UndecidableInstances
ViewPatterns

if flag(dev)
default-extensions: PartialTypeSignatures

default-language: GHC2021

common common-onchain
Expand All @@ -75,9 +81,6 @@ common common-onchain
if !flag(dev)
ghc-options: -fplugin-opt PlutusTx.Plugin:defer-errors

-- Options for Plutus Tx compilations
-- (some are enabled additionaly in individual modules)

ghc-options:
-fplugin-opt PlutusTx.Plugin:target-version=1.0.0 -fobject-code
-fno-ignore-interface-pragmas -fno-omit-interface-pragmas
Expand Down Expand Up @@ -116,9 +119,9 @@ common common-executable

library data-spine
import: common-lang
hs-source-dirs: src-lib/data-spine
hs-source-dirs: lib/data-spine

-- FIXME: was not meant to be dependent on Plutus...
-- TODO: Originally was not meant to be dependent on Plutus
build-depends:
, plutus-tx
, singletons
Expand All @@ -131,12 +134,11 @@ library cardano-extras
common-offchain,
common-onchain

hs-source-dirs: src-lib/cardano-extras
hs-source-dirs: lib/cardano-extras
build-depends: template-haskell
exposed-modules:
Cardano.Extras
Plutarch.Extras
Plutus.Deriving
Plutus.Extras

library
Expand All @@ -147,55 +149,100 @@ library
hs-source-dirs: src/
exposed-modules:
Cardano.CEM
Cardano.CEM.Indexing
Cardano.CEM.Testing.StateMachine

other-modules:
Cardano.CEM.Address
Cardano.CEM.Compile
Cardano.CEM.Documentation
Cardano.CEM.DSL
Cardano.CEM.Examples.Auction
Cardano.CEM.Examples.Compilation
Cardano.CEM.Examples.Voting
Cardano.CEM.Indexing.Event
Cardano.CEM.Indexing.Oura
Cardano.CEM.Indexing.Tx
Cardano.CEM.Monads
Cardano.CEM.Monads.CLB
Cardano.CEM.Monads.L1
Cardano.CEM.Monads.L1Commons
Cardano.CEM.OffChain
Cardano.CEM.OnChain
Cardano.CEM.Testing.StateMachine
Cardano.CEM.Smart
Cardano.CEM.TH

other-modules: Cardano.CEM.Monads.L1Commons
build-depends:
, base16
, base64
, cem-script:cardano-extras
, cem-script:data-spine
, clb
, dependent-map
, lens
, ouroboros-consensus
, QuickCheck
, quickcheck-dynamic
, safe
, singletons-th
, toml-parser
, vector

library cem-script-example
import:
, common-lang
, common-onchain

hs-source-dirs: example
build-depends: cem-script
exposed-modules:
CEM.Example.Auction
CEM.Example.Compiled
CEM.Example.Voting

test-suite cem-sdk-test
test-suite cem-script-test
import:
common-onchain,
common-offchain,

type: exitcode-stdio-1.0
ghc-options: -Wno-missing-signatures -Wno-incomplete-uni-patterns
ghc-options:
-threaded -Wno-missing-signatures -Wno-incomplete-uni-patterns

build-depends:
, aeson
, async
, base16
, base32
, base64
, cardano-api
, cardano-ledger-core
, cem-script
, cem-script:cardano-extras
, cem-script:cem-script-example
, cem-script:data-spine
, clb
, dependent-map
, directory
, hspec
, hspec-core
, lens
, network
, process
, QuickCheck
, quickcheck-dynamic
, random
, safe
, toml-parser
, vector

hs-source-dirs: test/
other-modules:
Auction
Dynamic
OffChain
TestNFT
Utils
Voting
CEM.Test.Auction
CEM.Test.Dynamic
CEM.Test.OffChain
CEM.Test.Oura.Communication
CEM.Test.OuraFilters.Auction
CEM.Test.OuraFilters.Mock
CEM.Test.OuraFilters.Simple
CEM.Test.TestNFT
CEM.Test.Utils
CEM.Test.Voting

main-is: Main.hs
19 changes: 9 additions & 10 deletions docs/arch_principles.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@

## Principles

* Generic compilation across: on-chain code,
offchain Tx construction and indexing backend
* Generic compilation across:
* on-chain code
* offchain Tx construction
* indexing backend
* Simple normalization and SMT conversion for:
* Equivalence checking
* Bi-simulation checking
* Constraints determine TxIn/Outs up to UTxO coin-selection
(we call it almost-determinacy)
* Constraints determine TxIn/Outs up to UTxO coin-selection (we call it almost-determinacy)
* Datum properties encoded as class types
* Common on-chain optimizations are performed if possible
* Constraints normalization, and CSE
* Constraints normalization, and CSE
* Best error short-cutting
* Common security problems prevention

## Potential obstacles

* Ease and optimality of backend compilation
* Robustness of SMT conversion and overall normalization
* Possibility for parsing and correct offchain usage
of almost-determinacy
* Possibility for parsing and correct offchain usage of almost-determinacy
* Having enough information for Tx submit retrying strategies
* Design for using custom Datum properties is not obvious

Expand All @@ -32,9 +32,8 @@ all their principles and obstacles are affecting CEM as well.
## Principles

* State-machine is deterministic modulo coin-change
* Transaction can always be parsed back into SM transitions
* Potential non-deterministic on-chain optimizations
should not affect this principle.
* Transaction can always be parsed back into SM transitions
* Potential non-deterministic on-chain optimizations should not affect this principle.

## Potential obstacles

Expand Down
74 changes: 43 additions & 31 deletions docs/catalyst_milestone_reports.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,14 @@
# Milestone 3
# Milestone 5

## Summary

Changes:

* Running in emulated environment by CLB
([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),
[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,
[PR](https://github.com/mlabs-haskell/cem-script/pull/33))

## State graph examples

![](./auction-state-graph.svg)


Source code:

```
digraph Creator {
rankdir=LR;
node [shape="dot",fontsize=14,fixedsize=true,width=1.5];
edge [fontsize=11];"Void In" [color="orange"];"Void Out" [color="orange"];"Void In" -> NotStarted [label="Create (stage Open)"];
NotStarted -> CurrentBid [label="Start (stage Open)"];
CurrentBid -> CurrentBid [label="MakeBid (stage Open)"];
CurrentBid -> Winner [label="Close (stage Closed)"];
Winner -> "Void Out" [label="Buyout (stage Closed)"];
}
```
* L1 indexing:
* [Basic indexing support PR #98](https://github.com/mlabs-haskell/cem-script/pull/98)
* [Oura config generation PR #100](https://github.com/mlabs-haskell/cem-script/pull/100)
* [Source](https://github.com/mlabs-haskell/cem-script/blob/master/src/Cardano/CEM/Indexing.hs)
* [Tests for Auction example](https://github.com/mlabs-haskell/cem-script/blob/master/test/OuraFilter/Auction.hs)
* Final code clean-up
* Final tutorial and docs

## Clarifications on M3 Deliverables

Expand Down Expand Up @@ -163,3 +140,38 @@ Voting Plutarch backend:
)
]
```

# Milestone 3

## Summary

Changes:

* Running in emulated environment by CLB
([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),
[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,
[PR](https://github.com/mlabs-haskell/cem-script/pull/33))

## State graph examples

![](./auction-state-graph.svg)


Source code:

```
digraph Creator {
rankdir=LR;
node [shape="dot",fontsize=14,fixedsize=true,width=1.5];
edge [fontsize=11];"Void In" [color="orange"];"Void Out" [color="orange"];"Void In" -> NotStarted [label="Create (stage Open)"];
NotStarted -> CurrentBid [label="Start (stage Open)"];
CurrentBid -> CurrentBid [label="MakeBid (stage Open)"];
CurrentBid -> Winner [label="Close (stage Closed)"];
Winner -> "Void Out" [label="Buyout (stage Closed)"];
}
```
7 changes: 5 additions & 2 deletions docs/goals_and_soa.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

## Why Cardano DApp modeling language is important?

While prototypes can be easily constructed with existing Cardano frameworks, making it secure and production ready is sisyphean task.
While prototypes can be easily constructed with existing Cardano frameworks,
making it secure and production ready is sisyphean task.

We believe, that onchain PL improvements by themselves could not change that. Only higher-level modeling framework can lead to reliable DApp production.
We believe, that onchain PL improvements by themselves could not change that.
Only higher-level modeling framework can lead to reliable DApp production.

In following enumerate our high-level design goals
and demonstrate them by list of specific problems
arising in existing DApps codebase.

Such problems are specific security vulnerabilities types
and various kinds development, audit and support cost increase.
After that we examine how existing solutions
Expand Down
Loading
Loading