Skip to content

Commit

Permalink
Updated blockly examples; move static analysis to guide referenced in…
Browse files Browse the repository at this point in the history
… concepts
  • Loading branch information
sfoo-iohk committed Nov 30, 2023
1 parent 618aa16 commit a1a5fe5
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 13 deletions.
Binary file modified static/img/analysis1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/img/analysis2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/img/analysis3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/img/analysis4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tutorials/concepts/playground-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ say that the contract passed all the tests, or to explain how it fails,
and giving the sequence of transactions that lead to the error. As an
exercise, try this with the `Escrow` contract, changing the initial
deposit from Alice to something smaller than 450 lovelace. More details
are given in the section on [static analysis](static-analysis.md) below.
are given in the section on [static analysis](/tutorials/guides/static-analysis).

The **Analyse reachability** button will check whether any parts of a
contract will never be executed, however participants interact with the
Expand Down
18 changes: 10 additions & 8 deletions tutorials/concepts/potential-problems-with-contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ can issue warnings from being ever written, but that would require
Marlowe contracts to be dependently-typed, and writing expressions that
are dependently-typed is much more cumbersome.

Instead, Marlowe allows contracts that issue warning to be written, and
we provide [static analysis tools](static-analysis.md) that let contract
developers check whether a particular contract can possibly issue
warnings. Additionally, we provide fall-back behaviours for when a
contract produces a warning, despite our advice. We provide fall-back
behaviours because we acknowledge that analysing big contracts can be
very computationally expensive, and because mistakes can be made. We
want badly written contracts to fail in the most harmless way possible,
### Static analysis

Marlowe allows contracts that issue warning to be written, and
we provide [static analysis tools](/tutorials/guides/static-analysis)
that let contract developers check whether a particular contract can
possibly issue warnings. Additionally, we provide fall-back behaviours
for when a contract produces a warning, despite our advice. We provide
fall-back behaviours because we acknowledge that analysing big contracts
can be very computationally expensive, and because mistakes can be made.
We want badly written contracts to fail in the most harmless way possible,
that is conservatively.

### Non-positive payments
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
title: Static analysis
sidebar_position: 9
title: Static analysis using Blockly
sidebar_position: 7
---

# Static analysis
# Static analysis using Blockly

One distinctive feature of Marlowe -- probably its most distinctive
feature -- is that we can analyze contracts, and deduce properties of
Expand All @@ -26,7 +26,7 @@ the account) to make a complete payment.

## An example

Let us look at this example, in Blockly:
Let us look at this example, in [Blockly](https://play.marlowe.iohk.io/#/blockly):

![An example contract in Blockly](/img/analysis1.png)

Expand Down Expand Up @@ -59,6 +59,45 @@ succeed:

![Successful analysis](/img/analysis4.png)

The corrected contract is shown below:

```
When
[Case
(Deposit
(Role "alice")
(Role "alice")
(Token "" "")
(Constant 2)
)
(When
[Case
(Choice
(ChoiceId
"bool"
(Role "bob")
)
[Bound 0 1]
)
(Pay
(Role "alice")
(Party (Role "bob"))
(Token "" "")
(AddValue
(Constant 1)
(ChoiceValue
(ChoiceId
"bool"
(Role "bob")
))
)
Close
)]
1677621600000 Close
)]
1675202400000 Close
```

## Under the hood

Just to re-iterate: the effect of this analysis is to check *every
Expand Down

0 comments on commit a1a5fe5

Please sign in to comment.