Skip to content

Commit 3abfdb7

Browse files
authored
Merge pull request #98 from mlabs-haskell/alexey/test-oura-filters
L1 chain indexing
2 parents 0bebafd + 713fc36 commit 3abfdb7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+4180
-2118
lines changed

.ghcid

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
--command="cabal repl test-suite:cem-sdk-test" -W -T ":main"
1+
--command="cabal repl test-suite:cem-script-test" -W -T ":main"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ haddocks
2727
# Functions changed by runing local testnet
2828
devnet/db
2929
devnet/genesis-*.json
30+
test.log

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.PHONY: run-oura-daemon
2+
3+
clear-sockets:
4+
@rm ./oura-daemon-cursor || true
5+
@rm ./oura-listening.socket || true
6+
@rm ./own.socket || true
7+
8+
run-oura-daemon:
9+
@clear-sockets || true
10+
@oura daemon --config ./test/daemon.toml
11+
12+
format:
13+
fourmolu --mode inplace $$(git ls-files '*.hs')

cabal.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ source-repository-package
2222
tag: d5b0e7ce07258482d53704ce19383013b1fa6610
2323
--sha256: 6+Os/mQDzBOU+TkTD+n/T1MFcI+Mn0/tcBMJhLRfqyA=
2424

25-
-- FIXME: Cannot use new commit, because it requires `plutus-ledger-api==1.29`
25+
-- Cannot use new commit, because it requires `plutus-ledger-api==1.29`
2626
source-repository-package
2727
type: git
2828
location: https://github.com/Plutonomicon/plutarch-plutus

cem-script.cabal

Lines changed: 76 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
cabal-version: 3.8
22
name: cem-script
33
version: 0.1.0
4-
synopsis: Cardano DApp SDK
5-
homepage: https://github.com/cem-script
4+
synopsis: CEM Script - a Cardano dApp SDK
5+
homepage: https://github.com/mlabs-haskell/cem-script
66
author: MLabs
7-
maintainer: gregory@mlabs.city
7+
maintainer: ilia@mlabs.city
88
data-files: README.md
99
tested-with: GHC ==9.6.3
1010

@@ -15,9 +15,11 @@ flag dev
1515
default: True
1616
manual: False
1717

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

22+
common common-lang
2123
ghc-options:
2224
-Wall -Wcompat -Wincomplete-record-updates
2325
-Wincomplete-uni-patterns -Wredundant-constraints
@@ -26,9 +28,16 @@ common common-lang
2628
if !flag(dev)
2729
ghc-options: -Werror
2830

31+
if flag(dev)
32+
default-extensions: PartialTypeSignatures
33+
34+
if flag(force-recomp)
35+
ghc-options: -fforce-recomp -Wunused-packages
36+
2937
build-depends:
3038
, base
3139
, containers
40+
, extra
3241
, mtl
3342
, transformers
3443

@@ -54,9 +63,6 @@ common common-lang
5463
UndecidableInstances
5564
ViewPatterns
5665

57-
if flag(dev)
58-
default-extensions: PartialTypeSignatures
59-
6066
default-language: GHC2021
6167

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

78-
-- Options for Plutus Tx compilations
79-
-- (some are enabled additionaly in individual modules)
80-
8184
ghc-options:
8285
-fplugin-opt PlutusTx.Plugin:target-version=1.0.0 -fobject-code
8386
-fno-ignore-interface-pragmas -fno-omit-interface-pragmas
@@ -116,9 +119,9 @@ common common-executable
116119

117120
library data-spine
118121
import: common-lang
119-
hs-source-dirs: src-lib/data-spine
122+
hs-source-dirs: lib/data-spine
120123

121-
-- FIXME: was not meant to be dependent on Plutus...
124+
-- TODO: Originally was not meant to be dependent on Plutus
122125
build-depends:
123126
, plutus-tx
124127
, singletons
@@ -131,12 +134,11 @@ library cardano-extras
131134
common-offchain,
132135
common-onchain
133136

134-
hs-source-dirs: src-lib/cardano-extras
137+
hs-source-dirs: lib/cardano-extras
135138
build-depends: template-haskell
136139
exposed-modules:
137140
Cardano.Extras
138141
Plutarch.Extras
139-
Plutus.Deriving
140142
Plutus.Extras
141143

142144
library
@@ -147,55 +149,100 @@ library
147149
hs-source-dirs: src/
148150
exposed-modules:
149151
Cardano.CEM
152+
Cardano.CEM.Indexing
153+
Cardano.CEM.Testing.StateMachine
154+
155+
other-modules:
156+
Cardano.CEM.Address
157+
Cardano.CEM.Compile
150158
Cardano.CEM.Documentation
151159
Cardano.CEM.DSL
152-
Cardano.CEM.Examples.Auction
153-
Cardano.CEM.Examples.Compilation
154-
Cardano.CEM.Examples.Voting
160+
Cardano.CEM.Indexing.Event
161+
Cardano.CEM.Indexing.Oura
162+
Cardano.CEM.Indexing.Tx
155163
Cardano.CEM.Monads
156164
Cardano.CEM.Monads.CLB
157-
Cardano.CEM.Monads.L1
165+
Cardano.CEM.Monads.L1Commons
158166
Cardano.CEM.OffChain
159167
Cardano.CEM.OnChain
160-
Cardano.CEM.Testing.StateMachine
168+
Cardano.CEM.Smart
161169
Cardano.CEM.TH
162170

163-
other-modules: Cardano.CEM.Monads.L1Commons
164171
build-depends:
172+
, base16
173+
, base64
165174
, cem-script:cardano-extras
166175
, cem-script:data-spine
167176
, clb
168177
, dependent-map
178+
, lens
169179
, ouroboros-consensus
170180
, QuickCheck
171181
, quickcheck-dynamic
182+
, safe
172183
, singletons-th
184+
, toml-parser
185+
, vector
186+
187+
library cem-script-example
188+
import:
189+
, common-lang
190+
, common-onchain
191+
192+
hs-source-dirs: example
193+
build-depends: cem-script
194+
exposed-modules:
195+
CEM.Example.Auction
196+
CEM.Example.Compiled
197+
CEM.Example.Voting
173198

174-
test-suite cem-sdk-test
199+
test-suite cem-script-test
175200
import:
176201
common-onchain,
177202
common-offchain,
178203

179204
type: exitcode-stdio-1.0
180-
ghc-options: -Wno-missing-signatures -Wno-incomplete-uni-patterns
205+
ghc-options:
206+
-threaded -Wno-missing-signatures -Wno-incomplete-uni-patterns
207+
181208
build-depends:
209+
, aeson
210+
, async
211+
, base16
212+
, base32
213+
, base64
214+
, cardano-api
215+
, cardano-ledger-core
182216
, cem-script
183217
, cem-script:cardano-extras
218+
, cem-script:cem-script-example
184219
, cem-script:data-spine
185220
, clb
186221
, dependent-map
222+
, directory
187223
, hspec
224+
, hspec-core
225+
, lens
226+
, network
227+
, process
188228
, QuickCheck
189229
, quickcheck-dynamic
190230
, random
231+
, safe
232+
, toml-parser
233+
, vector
191234

192235
hs-source-dirs: test/
193236
other-modules:
194-
Auction
195-
Dynamic
196-
OffChain
197-
TestNFT
198-
Utils
199-
Voting
237+
CEM.Test.Auction
238+
CEM.Test.Dynamic
239+
CEM.Test.OffChain
240+
CEM.Test.Oura.Communication
241+
CEM.Test.OuraFilters.Auction
242+
CEM.Test.OuraFilters.Mock
243+
CEM.Test.OuraFilters.Simple
244+
CEM.Test.TestNFT
245+
CEM.Test.Utils
246+
CEM.Test.Voting
200247

201248
main-is: Main.hs

docs/arch_principles.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22

33
## Principles
44

5-
* Generic compilation across: on-chain code,
6-
offchain Tx construction and indexing backend
5+
* Generic compilation across:
6+
* on-chain code
7+
* offchain Tx construction
8+
* indexing backend
79
* Simple normalization and SMT conversion for:
810
* Equivalence checking
911
* Bi-simulation checking
10-
* Constraints determine TxIn/Outs up to UTxO coin-selection
11-
(we call it almost-determinacy)
12+
* Constraints determine TxIn/Outs up to UTxO coin-selection (we call it almost-determinacy)
1213
* Datum properties encoded as class types
1314
* Common on-chain optimizations are performed if possible
14-
* Constraints normalization, and CSE
15+
* Constraints normalization, and CSE
1516
* Best error short-cutting
1617
* Common security problems prevention
1718

1819
## Potential obstacles
1920

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

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

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

3938
## Potential obstacles
4039

docs/catalyst_milestone_reports.md

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,14 @@
1-
# Milestone 3
1+
# Milestone 5
22

33
## Summary
44

5-
Changes:
6-
7-
* Running in emulated environment by CLB
8-
([source](https://github.com/mlabs-haskell/cem-script/blob/master/src/Cardano/CEM/Monads/CLB.hs), usage examples are all unit tests)
9-
* Running Quickcheck Dynamic tests, including mutation support
10-
([source](https://github.com/mlabs-haskell/cem-script/blob/master/src/Cardano/CEM/Testing/StateMachine.hs),
11-
[usage example](https://github.com/mlabs-haskell/cem-script/blob/master/test/Dynamic.hs),
12-
[PR](https://github.com/mlabs-haskell/cem-script/pull/75) and [PR2](https://github.com/mlabs-haskell/cem-script/pull/89))
13-
* Rendering CEMScript state graphs
14-
([source](https://github.com/mlabs-haskell/cem-script/blob/master/src/Cardano/CEM/Documentation.hs), rendered example below,
15-
[PR](https://github.com/mlabs-haskell/cem-script/pull/33))
16-
17-
## State graph examples
18-
19-
![](./auction-state-graph.svg)
20-
21-
22-
Source code:
23-
24-
```
25-
digraph Creator {
26-
rankdir=LR;
27-
node [shape="dot",fontsize=14,fixedsize=true,width=1.5];
28-
edge [fontsize=11];"Void In" [color="orange"];"Void Out" [color="orange"];"Void In" -> NotStarted [label="Create (stage Open)"];
29-
NotStarted -> CurrentBid [label="Start (stage Open)"];
30-
CurrentBid -> CurrentBid [label="MakeBid (stage Open)"];
31-
CurrentBid -> Winner [label="Close (stage Closed)"];
32-
Winner -> "Void Out" [label="Buyout (stage Closed)"];
33-
}
34-
```
5+
* L1 indexing:
6+
* [Basic indexing support PR #98](https://github.com/mlabs-haskell/cem-script/pull/98)
7+
* [Oura config generation PR #100](https://github.com/mlabs-haskell/cem-script/pull/100)
8+
* [Source](https://github.com/mlabs-haskell/cem-script/blob/master/src/Cardano/CEM/Indexing.hs)
9+
* [Tests for Auction example](https://github.com/mlabs-haskell/cem-script/blob/master/test/OuraFilter/Auction.hs)
10+
* Final code clean-up
11+
* Final tutorial and docs
3512

3613
## Clarifications on M3 Deliverables
3714

@@ -163,3 +140,38 @@ Voting Plutarch backend:
163140
)
164141
]
165142
```
143+
144+
# Milestone 3
145+
146+
## Summary
147+
148+
Changes:
149+
150+
* Running in emulated environment by CLB
151+
([source](https://github.com/mlabs-haskell/cem-script/blob/master/src/Cardano/CEM/Monads/CLB.hs), usage examples are all unit tests)
152+
* Running Quickcheck Dynamic tests, including mutation support
153+
([source](https://github.com/mlabs-haskell/cem-script/blob/master/src/Cardano/CEM/Testing/StateMachine.hs),
154+
[usage example](https://github.com/mlabs-haskell/cem-script/blob/master/test/Dynamic.hs),
155+
[PR](https://github.com/mlabs-haskell/cem-script/pull/75) and [PR2](https://github.com/mlabs-haskell/cem-script/pull/89))
156+
* Rendering CEMScript state graphs
157+
([source](https://github.com/mlabs-haskell/cem-script/blob/master/src/Cardano/CEM/Documentation.hs), rendered example below,
158+
[PR](https://github.com/mlabs-haskell/cem-script/pull/33))
159+
160+
## State graph examples
161+
162+
![](./auction-state-graph.svg)
163+
164+
165+
Source code:
166+
167+
```
168+
digraph Creator {
169+
rankdir=LR;
170+
node [shape="dot",fontsize=14,fixedsize=true,width=1.5];
171+
edge [fontsize=11];"Void In" [color="orange"];"Void Out" [color="orange"];"Void In" -> NotStarted [label="Create (stage Open)"];
172+
NotStarted -> CurrentBid [label="Start (stage Open)"];
173+
CurrentBid -> CurrentBid [label="MakeBid (stage Open)"];
174+
CurrentBid -> Winner [label="Close (stage Closed)"];
175+
Winner -> "Void Out" [label="Buyout (stage Closed)"];
176+
}
177+
```

docs/goals_and_soa.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22

33
## Why Cardano DApp modeling language is important?
44

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

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

911
In following enumerate our high-level design goals
1012
and demonstrate them by list of specific problems
1113
arising in existing DApps codebase.
14+
1215
Such problems are specific security vulnerabilities types
1316
and various kinds development, audit and support cost increase.
1417
After that we examine how existing solutions

0 commit comments

Comments
 (0)