Skip to content

Commit

Permalink
Merge pull request #129 from input-output-hk/sprint-56
Browse files Browse the repository at this point in the history
Sprint 56
  • Loading branch information
bwbush committed May 23, 2022
2 parents 548a074 + 57f5845 commit 691c7ef
Show file tree
Hide file tree
Showing 240 changed files with 7,935 additions and 2,797 deletions.
28 changes: 17 additions & 11 deletions bitte/pab.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ let
scriptsFeeFactor = 1.0; # Factor by which to multiply the size-dependent scripts fee in lovelace

pabYamlIn = writeText "pab.yaml.in" (builtins.toJSON {
dbConfig = {
dbConfigFile = "@PAB_STATE_DIR@/pab.db";
dbConfigPoolSize = 20;
contractStoreConfig = {
tag = "UseFSStore";
contents = "@PAB_STATE_DIR@/contract-store";
};

pabWebserverConfig = {
Expand Down Expand Up @@ -73,7 +73,7 @@ let
};

developmentOptions = {
pabRollbackHistory = null;
pabRollbackHistory = 100;
pabResumeFrom = {
tag = "PointAtGenesis";
};
Expand All @@ -82,6 +82,8 @@ let

dbFile = "$PAB_STATE_DIR/pab.db";

fsStore = "$PAB_STATE_DIR/contract-store";

# Note: The db is dropped as a workaround for a problem with
# eventful which crashes PAB. Currently data persistence is not
# relevant, but the problem *will* occur again when the DB removal
Expand All @@ -92,8 +94,11 @@ let
echo "[pab-init-cmd]: Dropping PAB database file '${dbFile}'" >&2
rm -rf "${dbFile}"
echo "[pab-init-cmd]: Creating new DB '${dbFile}'" >&2
${pabExe} --config=pab.yaml migrate
# Uncomment when using SQLite
# echo "[pab-init-cmd]: Creating new DB '${dbFile}'" >&2
# ${pabExe} --config=pab.yaml migrate
mkdir -p ${fsStore}
'';
in
writeShellScriptBin "entrypoint" ''
Expand All @@ -103,6 +108,8 @@ writeShellScriptBin "entrypoint" ''
export SYSTEM_CERTIFICATE_PATH=${cacert}/etc/ssl/certs/ca-bundle.crt
# Always start fresh
rm -fR "$PAB_STATE_DIR"
mkdir -p "$PAB_STATE_DIR"
sed -e "s|@PAB_STATE_DIR@|$PAB_STATE_DIR|g" \
Expand All @@ -115,12 +122,11 @@ writeShellScriptBin "entrypoint" ''
wait-for-socket "$NOMAD_ALLOC_DIR/node.sock"
# not needed with --memory
# ${pab-init-cmd}/bin/pab-init-cmd
${pab-init-cmd}/bin/pab-init-cmd
# Ugly ugly hack to kill the PAB at midnight UTC
${pabExe} --config=pab.yaml webserver --passphrase fixme-allow-pass-per-wallet --memory &
sleep $(($(date -f - +%s- <<< $'tomorrow 00:00\nnow')0))&
# Ugly ugly hack to kill the PAB every hour
${pabExe} --config=pab.yaml webserver --passphrase fixme-allow-pass-per-wallet &
sleep 3600&
wait -n
exit 1
''
7 changes: 6 additions & 1 deletion bitte/wbe.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,10 @@ writeShellScriptBin "entrypoint" ''
wait-for-socket "$NOMAD_ALLOC_DIR/node.sock"
exec cardano-wallet serve --listen-address '*' --port "$NOMAD_PORT_wbe" --node-socket "$NOMAD_ALLOC_DIR/node.sock" --testnet ${network.networkConfig.ByronGenesisFile} --log-level DEBUG
# Ugly ugly hack to kill the WBE every hour
cardano-wallet serve --listen-address '*' --port "$NOMAD_PORT_wbe" --node-socket "$NOMAD_ALLOC_DIR/node.sock" --testnet ${network.networkConfig.ByronGenesisFile} --log-level DEBUG&
sleep 3600&
wait -n
exit 1
''
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ package cardano-wallet-core-integration
source-repository-package
type: git
location: https://github.com/input-output-hk/plutus-apps
tag: 2d2c0f37d66d28a86accaa0d312fd547f54a850a
tag: f3278f5d6db2476174985ef5ea851a2dbd57f0b7
subdir:
freer-extras
playground-common
Expand Down
2 changes: 1 addition & 1 deletion ci.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# 'supportedSystems' restricts the set of systems that we will evaluate for. Useful when you're evaluting
# on a machine with e.g. no way to build the Darwin IFDs you need!
# TODO re-enable Darwin after Hydra Darwin build issues are resolved.
supportedSystems ? [ "x86_64-linux" /* "x86_64-darwin" */ ]
supportedSystems ? [ "x86_64-linux" "x86_64-darwin" ]
, rootsOnly ? false
# We explicitly pass true here in the GitHub action but don't want to slow down hydra
, checkMaterialization ? false
Expand Down
28 changes: 13 additions & 15 deletions doc/marlowe/tutorials/actus-marlowe.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ the bond is redeemed for its full face value.

For example, an ``investor`` can buy a bond that costs 1000 Lovelace
with 15% discount. She pays 850 Lovelace to the bond issuer before
*start time*, here ``10``.
*start time*, here ``1672531200`` (2023-01-01 00:00:00 GMT).

Later, after *maturity date*, time ``20`` here, the investor can
One month later, after *maturity date*, time ``1675209600``
(2023-02-01 00:00:00 GMT) here, the investor can
exchange the bond for its full notional, i.e. 1000 Lovelace.

.. code:: haskell
Expand All @@ -69,10 +70,10 @@ exchange the bond for its full notional, i.e. 1000 Lovelace.
(Constant 1000)
Close))
]
20
1675209600
Close)))
]
10
1672531200
Close
This contract has a significant drawback. Once the ``investor`` has
Expand All @@ -83,7 +84,7 @@ ends). After that, two outcomes are possible
- the ``issuer`` deposits 1000 Lovelace in the ``investor``'s account,
and that is then immediately paid to the ``investor`` in full;

- if the ``investor`` doesnt make the deposit, then the contract is
- if the ``investor`` doesn't make the deposit, then the contract is
closed and all the money in the contract is refunded, but there is
*no* money in the contract at this point, so the ``investor`` loses
her money.
Expand Down Expand Up @@ -116,7 +117,7 @@ Guaranteed Coupon Bond Example

This more complex bond involves an ``investor`` who deposits 1000
Lovelace, which is immediately paid to the ``issuer``. The ``issuer``
then has to pay as interest 10 Lovelace every 10 slots. On maturity the
then has to pay as interest 10 Lovelace every month. On maturity the
investor should receive back the interest plus the full value of the
bond.

Expand All @@ -127,24 +128,24 @@ bond.
When [ Case (Deposit "investor" "investor" ada (Constant 1000))
-- and pays it to the issuer
(Pay "investor" (Party "issuer") ada (Constant 1000)
-- after 10 slots expect to receive 10 Lovelace interest
-- after 1 month expect to receive 10 Lovelace interest
(When [ Case (Deposit "investor" "issuer" ada (Constant 10))
-- and pay it to the investor
(Pay "investor" (Party "investor" ) ada (Constant 10)
-- same for 2nd 10 slots
-- same for 2nd month
(When [ Case (Deposit "investor" "issuer" ada (Constant 10))
(Pay "investor" (Party "investor" ) ada (Constant 10)
-- after maturity date investor
-- expects to receive notional + interest payment
(When [ Case (Deposit "investor" "issuer" ada (Constant 1010))
(Pay "investor" (Party "investor" ) ada (Constant 1010) Close)]
(Slot 40)
1680307200 -- 2023-04-01 00:00:00 GMT
Close))]
(Slot 30)
1677628800 -- 2023-03-01 00:00:00 GMT
Close))]
(Slot 20)
1675209600 -- 2023-02-01 00:00:00 GMT
Close))]
(Slot 10)
1672531200 -- 2023-01-01 00:00:00 GMT
Close
..
Expand All @@ -156,6 +157,3 @@ bond.
before the bond is issued, and who will pay that counterparty if the
issuer defaults; if the issuer does make the payment in time, then
the guarantor should recover their money.

IOHK plans to implement the full ACTUS standard using Marlowe and Plutus
over the coming year.
31 changes: 15 additions & 16 deletions doc/marlowe/tutorials/embedded-marlowe.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ contract:
contract :: Contract
contract = When [Case (Deposit "alice" "alice" ada price) inner]
10
1700000000
Close
inner :: Contract
inner =
When [ Case aliceChoice
(When [ Case bobChoice
(If (aliceChosen `ValueEQ` bobChosen)
agreement
arbitrate) ]
60
agreement
arbitrate) ]
1700007200
arbitrate)
]
40
Close
]
1700003600
Close
Many of the terms here are themselves defined within Haskell.
Principally, we have the two contracts that deal with what happens when
Expand All @@ -50,17 +50,16 @@ should ``arbitrate`` between them:
agreement :: Contract
agreement =
If
(aliceChosen `ValueEQ` (Constant 0))
(Pay "alice" (Party "bob") ada price Close)
Close
If (aliceChosen `ValueEQ` (Constant 0))
(Pay "alice" (Party "bob") ada price Close)
Close
arbitrate :: Contract
arbitrate =
When [ Case carolClose Close,
Case carolPay (Pay "alice" (Party "bob") ada price Close) ]
100
Close
When [ Case carolClose Close,
Case carolPay (Pay "alice" (Party "bob") ada price Close) ]
1700010800
Close
Within these contracts we are also using simple abbreviations such as:

Expand All @@ -73,7 +72,7 @@ which indicates the price of the cat, and so the value of the money
under escrow.

We can also describe the choices made by Alice and Bob, noting that
were also asked for a default value ``defValue`` just in case the
we're also asked for a default value ``defValue`` just in case the
choices have not been made.

.. code:: haskell
Expand Down
50 changes: 26 additions & 24 deletions doc/marlowe/tutorials/escrow-ex.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ choice, rather than ``alice``, like this:
(If (aliceChosen `ValueEQ` bobChosen)
agreement
arbitrate) ],
Case bobChoice
Case bobChoice
(When [ Case aliceChoice
(If (aliceChosen `ValueEQ` bobChosen)
agreement
Expand All @@ -60,7 +60,7 @@ choice, rather than ``alice``, like this:
In this contract, either Alice or Bob can make the first choice; the
other then makes a choice. If they agree, then that is done; if not,
Carol arbitrates. In the remainder of the tutorial well revert to the
Carol arbitrates. In the remainder of the tutorial we'll revert to the
simpler version where ``alice`` chooses first.

**Exercise**
Expand Down Expand Up @@ -99,26 +99,27 @@ contract.
(If (aliceChosen `ValueEQ` bobChosen)
agreement
arbitrate) ]
60 -- ADDED
1700007200 -- ADDED
arbitrate) -- ADDED
]
40 -- ADDED
1700003600 -- ADDED
Close -- ADDED
The outermost ``When`` calls for the first choice to be made by Alice:
if Alice has not made a choice by slot ``40``, the contract is closed
and all the funds in the contract are refunded.
if Alice has not made a choice by POSIX time ``1700003600`` (2023-11-14 23:13:20 GMT),
the contract is closed and all the funds in the contract are refunded.

``Close`` is typically the last step in every “path” through a Marlowe
contract, and its effect is to refund the money in the contract to the
participants; we will describe this in more detail when we look at
:ref:`Marlowe step by step <marlowe-step-by-step>`
in a later tutorial. In this particular case, refund will happen at slot
number ``40``.
in a later tutorial. In this particular case, refund will happen at
POSIX time ``1700003600`` (2023-11-14 23:13:20 GMT).

Looking at the inner constructs, if Alice’s choice has been made, then
we wait for one from Bob. If that is not forthcoming by slot ``60``,
then Carol is called upon to arbitrate. [2]_
Looking at the inner constructs, if Alice's choice has been made, then
we wait for one from Bob. If that is not forthcoming by POSIX time
``1700007200`` (2023-11-15 00:13:20 GMT), then Carol is called upon
to arbitrate. [2]_

Adding commitments
------------------
Expand All @@ -134,24 +135,24 @@ contract.
(If (aliceChosen `ValueEQ` bobChosen)
agreement
arbitrate) ]
60
1700007200
arbitrate)
]
40
1700003600
Close)
]
10 -- ADDED
1700000000 -- ADDED
Close -- ADDED
A deposit of ``price`` is requested from ``"alice"``: if it is given,
then it is held in an account, also called ``"alice"``. Accounts like
this exist for the life of the contract only; each account belongs to a
single contract.

There is a timeout at slot number ``10`` on making the deposit; if that
is reached without a deposit being made, the contract is closed and all
the money already in the contract is refunded. In this case, that is
simply the end of the contract.
There is a timeout at POSIX time ``1700000000`` (2023-11-14 22:13:20 GMT)
on making the deposit; if that is reached without a deposit being made,
the contract is closed and all the money already in the contract
is refunded. In this case, that is simply the end of the contract.

Definitions
-----------
Expand All @@ -169,10 +170,11 @@ Haskell <embedded-marlowe>`.

Comment on the choice of timeout values, and look at alternatives.

For example, what would happen if the timeout of ``40`` on the
``When`` were to be replaced by ``60``, and vice versa? Would it be
sensible to have the same timeout, of ``100`` say, on each ``When``?
If not, why not?
For example, what would happen if the timeout of ``1700003600``
(2023-11-14 23:13:20 GMT) on the ``When`` were to be replaced by
``1700007200`` (2023-11-15 00:13:20 GMT), and vice versa? Would it be
sensible to have the same timeout, of ``1700010800``
(2023-11-15 01:13:20 GMT) say, on each ``When``? If not, why not?

This example has shown many of the ingredients of the Marlowe contract
language; in the next tutorial we will present the language in full.
Expand All @@ -182,8 +184,8 @@ Notes

- While the names of Alice, Bob and so on are “hard wired” into the contract here,
we will see later on that these can be represented by *roles* in an account, such as *buyer* and *seller*.
These roles can then be associated with specific *participants* when a contract is run; we discuss this
further in the next section.
These roles can then be associated with specific *participants* when a contract is run;
we discuss this further in the next section.


Background
Expand Down
6 changes: 3 additions & 3 deletions doc/marlowe/tutorials/escrow-step-by-step.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Test cases:

- Alice authorizes payment

- Alice doesnt authorize
- Alice doesn't authorize

Contract 4. Pay unless explicit rejection
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -182,11 +182,11 @@ Marlowe code:

Test cases:

- Bob can collect even if Alice doesnt give an instruction.
- Bob can collect even if Alice doesn't give an instruction.

- Alice can cancel payment

- Bob cant claim payment before block 40 or approval from alice.
- Bob can't claim payment before block 40 or approval from alice.

Contract 5. Simple Escrow
~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
Binary file modified doc/marlowe/tutorials/images/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 doc/marlowe/tutorials/images/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 doc/marlowe/tutorials/images/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 doc/marlowe/tutorials/images/analysis4.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 doc/marlowe/tutorials/images/available-actions.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 removed doc/marlowe/tutorials/images/blocklyNew0.png
Binary file not shown.
Binary file added doc/marlowe/tutorials/images/blocklyNew00.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 added doc/marlowe/tutorials/images/blocklyNew01.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 added doc/marlowe/tutorials/images/blocklyNew02.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 added doc/marlowe/tutorials/images/blocklyNew03.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 added doc/marlowe/tutorials/images/blocklyNew04.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 added doc/marlowe/tutorials/images/blocklyNew05.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 added doc/marlowe/tutorials/images/blocklyNew06.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 added doc/marlowe/tutorials/images/blocklyNew07.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 added doc/marlowe/tutorials/images/blocklyNew08.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 added doc/marlowe/tutorials/images/blocklyNew09.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 removed doc/marlowe/tutorials/images/blocklyNew1-5.png
Binary file not shown.
Binary file removed doc/marlowe/tutorials/images/blocklyNew1.png
Binary file not shown.
Binary file modified doc/marlowe/tutorials/images/blocklyNew10.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 added doc/marlowe/tutorials/images/blocklyNew11.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 removed doc/marlowe/tutorials/images/blocklyNew2.png
Binary file not shown.
Binary file removed doc/marlowe/tutorials/images/blocklyNew3.png
Binary file not shown.
Binary file removed doc/marlowe/tutorials/images/blocklyNew4.png
Binary file not shown.
Binary file removed doc/marlowe/tutorials/images/blocklyNew5.png
Binary file not shown.
Binary file removed doc/marlowe/tutorials/images/blocklyNew6.png
Binary file not shown.
Binary file removed doc/marlowe/tutorials/images/blocklyNew7.png
Diff not rendered.
Binary file removed doc/marlowe/tutorials/images/blocklyNew8.png
Diff not rendered.
Binary file removed doc/marlowe/tutorials/images/blocklyNew9.png
Diff not rendered.
Binary file added doc/marlowe/tutorials/images/choose-template.png
Binary file modified doc/marlowe/tutorials/images/completed-params.png
Binary file added doc/marlowe/tutorials/images/contacts-tab.png
Binary file added doc/marlowe/tutorials/images/demo-launch.png
Binary file added doc/marlowe/tutorials/images/demo-wallet.png
Binary file modified doc/marlowe/tutorials/images/github1.png
Binary file modified doc/marlowe/tutorials/images/github2.png
Binary file modified doc/marlowe/tutorials/images/github3.png
Binary file modified doc/marlowe/tutorials/images/haskell-compiled.png
Binary file modified doc/marlowe/tutorials/images/haskell-editor.png
Binary file modified doc/marlowe/tutorials/images/haskell-errors.png
Binary file modified doc/marlowe/tutorials/images/haskell-metadata.png
Binary file modified doc/marlowe/tutorials/images/js-compiled.png
Binary file modified doc/marlowe/tutorials/images/js-editor-cont.png
Binary file modified doc/marlowe/tutorials/images/js-editor.png
Binary file modified doc/marlowe/tutorials/images/js-error.png
Binary file modified doc/marlowe/tutorials/images/js-metadata.png
Binary file modified doc/marlowe/tutorials/images/landing-page.png
Binary file modified doc/marlowe/tutorials/images/marlowe-editor.png
Binary file modified doc/marlowe/tutorials/images/marlowe-hole-fill.png
Binary file modified doc/marlowe/tutorials/images/open-example.png
Binary file modified doc/marlowe/tutorials/images/oracles1.png
Binary file modified doc/marlowe/tutorials/images/oracles2.png
Binary file added doc/marlowe/tutorials/images/pay-start.png
Binary file modified doc/marlowe/tutorials/images/simulation-tab.png
Binary file modified doc/marlowe/tutorials/images/simulation2.png
Binary file modified doc/marlowe/tutorials/images/simulation3.png
Binary file modified doc/marlowe/tutorials/images/static-analysis.png
Binary file added doc/marlowe/tutorials/images/steps-tab.png
Loading

0 comments on commit 691c7ef

Please sign in to comment.