Skip to content

Commit 7ccdfbd

Browse files
committed
Applied a patch by Ilia Rodionov
1 parent cc14c90 commit 7ccdfbd

File tree

1 file changed

+67
-51
lines changed

1 file changed

+67
-51
lines changed

README.md

Lines changed: 67 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Development of the COOP is led by [MLabs](https://mlabs.city/) with feedback and
4343
direction provided by the [Orcfax](https://www.orcfax.link/about/) oracle
4444
project which will implement the COOP on its platform.
4545

46-
This project was graciously funded from the Cardano Treasury in [Catalyst Fund
46+
This project was graciously funded by the Cardano Treasury in [Catalyst Fund
4747
8](https://cardano.ideascale.com/c/idea/402572).
4848

4949
## Documentation
@@ -54,7 +54,7 @@ The protocol is described in further detail in the following documents
5454
- [Plutus protocol](coop-docs/02-plutus-protocol.md) contains information about the wallets, tokens, minting policies, validators and transactions used in COOP and their relationship,
5555
- [Frontend protocol](coop-docs/03-frontend-protocol.md) contains information about how users must interact with the COOP Publisher in order to publish new Fact Statements and garbage collect obsolete Fact Statements,
5656
- [Backend protocol](coop-docs/04-backend-protocol.md) contains information on the back-end operations needed to serve the Frontend protocol,
57-
- [Mapping between JSON and Plutus Data](coop-docs/05-json-plutus.md) contains information about how JSON encodings maps into PlutusData encoding that can be used 'onchain'.
57+
- [Mapping between JSON and Plutus Data](coop-docs/05-json-plutus.md) contains information about how JSON encodings map into PlutusData encoding that can be used 'onchain'.
5858

5959
## Getting Started
6060

@@ -88,7 +88,7 @@ experimental-features = nix-command flakes
8888
allow-import-from-derivation = true
8989
```
9090

91-
Optionally, to improve build speed, it is possible to set up a binary caches
91+
Optionally, to improve build speed, it is possible to set up binary caches
9292
maintained by IOHK and Plutonomicon by setting additional configuration entries:
9393

9494
```yaml
@@ -121,9 +121,10 @@ nix profile install nixpkgs#nix-direnv
121121
Your shell and editors should pick up on the `.envrc` files in different
122122
directories and prepare the environment accordingly. Use `direnv allow` to
123123
enable the direnv environment and `direnv reload` to reload it when necessary.
124-
Otherwise, each `.envrc` file in COOP sub-directories contain a proper Nix
125-
target you can use with the `nix develop` command. For example `nix develop #dev-pab` will build a Nix development shell that has everything needed for
126-
developing and compiling the `coop-pab` component.
124+
Otherwise, each `.envrc` file in COOP sub-directories contains a proper Nix
125+
target you can use with the `nix develop` command.
126+
For example, `nix develop #dev-pab` will build a Nix development shell
127+
that has everything needed for developing and compiling the `coop-pab` component.
127128

128129
Additionally, throughout the repository one can use the [pre-commit](https://pre-commit.com/) tool:
129130

@@ -162,7 +163,7 @@ coop-get-state ()
162163
```
163164

164165
Additionally, each cli tool provided by COOP support a `--help` flag that
165-
provides detailed explanation on the purpose of commands and their options:
166+
provides the detailed explanation of the purpose of commands and their options:
166167

167168
```sh
168169
[coop-env ~ coop-tutorial] $ coop-plutus-cli --help
@@ -227,15 +228,15 @@ The environment should now have the following tools available:
227228

228229
- [cardano-node](https://github.com/input-output-hk/cardano-node#using-cardano-node) for running a Cardano network,
229230
- [cardano-cli](https://github.com/input-output-hk/cardano-node/tree/master/cardano-cli) for orchestrating a `cardano-node`, building, signing and submitting transactions,
230-
- [chain-index](https://github.com/input-output-hk/plutus-apps/tree/main/plutus-chain-index) for storing and indexing datums used by the [COOP Plutus protocol](coop-docs/02-plutus-protocol.md),
231+
- [plutus-chain-index](https://github.com/input-output-hk/plutus-apps/tree/main/plutus-chain-index) for storing and indexing datums used by the [COOP Plutus protocol](coop-docs/02-plutus-protocol.md),
231232
- [local-cluster](https://github.com/mlabs-haskell/plutip/tree/master/local-cluster) for running a local/private Cardano network,
232233
- [coop-pab-cli](coop-pab) for initializing and operating the [COOP Plutus Protocol](coop-docs/02-plutus-protocol.md) and operating the [COOP TxBuilder gRPC](coop-proto/tx-builder-service.proto) service,
233234
- [coop-plutus-cli](coop-plutus) for providing serialized Plutus programs (ie. on-chain scripts) that implement the [COOP Plutus Protocol](coop-docs/02-plutus-protocol.md),
234235
- [coop-publisher-cli](coop-publisher) for running a [COOP Publisher gRPC](coop-proto/publisher-service.proto) service that implements the [COOP Frontend protocol](coop-docs/03-frontend-protocol.md),
235236
- [json-fs-store-cli](coop-extras/json-fact-statement-store) for running a generic JSON-based implementation of the [COOP FactStatementStore gRPC](coop-proto/fact-statement-store-service.proto) service
236237
- [plutus-json-cli](coop-extras/plutus-json) utility tool for converting between JSON and PlutusData formats
237238

238-
and some other convenience utilities including some Bash functions that wrap the invocation of above mentioned services and command line tools.
239+
and some other convenience utilities including some Bash functions that wrap the invocation of the bove-mentioned services and command line tools.
239240

240241
#### 2. Environment variables and directories
241242

@@ -262,24 +263,21 @@ mkdir $CLUSTER_DIR $CLUSTER_DIR/scripts $CLUSTER_DIR/txs
262263

263264
#### 3. Running a local Cardano network
264265

265-
Let's first start by preparing and running a local Cardano network using the `local-cluster` utility tool:
266+
Let's first start by preparing and running a local Cardano network
267+
using the `local-cluster` utility tool
268+
from [Plutip](https://github.com/mlabs-haskell/plutip) library.
266269

267-
```sh
268-
export CLUSTER_DIR=.local-cluster WALLETS=.wallets
269-
local-cluster --dump-info-json $CLUSTER_DIR/local-cluster-info.json \
270-
--wallet-dir $WALLETS --num-wallets 10 --utxos 5 \
271-
--chain-index-port 9084 \
272-
--slot-len 1s --epoch-size 100000
273-
```
274-
275-
You should see the cluster running with instructions on how to stop it if
276-
necessary:
270+
You can use the provided `run-cluster` Bash function to run these commands for you
271+
(inspect the content with `type run-cluster`).
272+
You should see the cluster running with instructions on how to stop it if necessary:
277273

278274
```sh
275+
run-cluster
276+
...
279277
Cluster is running. Ctrl-C to stop.
280278
```
281279

282-
This creates the directories needed for the `local-cluster` to work and starts a Cardano network with 10 wallets (made available in the `$WALLETS` directory) that will be used in the Protocol. You can use the provided `run-cluster` Bash function to run these commands for you (inspect the content with `type run-cluster`).
280+
This creates the directories needed for the `local-cluster` to work and starts a Cardano network with 10 wallets (made available in the `$WALLETS` directory) that will be used in the Protocol.
283281

284282
Let's leave the `local-cluster` process running in the foreground of the current shell and open a new `[coop-env ~ coop-tutorial]` shell session to continue with the tutorial.
285283

@@ -302,7 +300,7 @@ declare -x GOD_PKH="c12aacc2604e89cd5dac1fb1e324ad552df1b18e2bd4230e8e15cfd5"
302300
declare -x SUBMITTER_PKH="b7e59f40866e6ec88635343b9cc285043d344afbbe001ae645db0553"
303301
```
304302

305-
Output shows some named wallets with their base16 public keys hash identifier. The `SUBMITTER_PKH` is the only wallet not used by the `COOP Publisher` that belongs to the user. In fact, we need to hide this wallet from the `local-cluster` as to emulate a real scenario:
303+
Output shows some named wallets with their base16 public keys hash identifier. The `SUBMITTER_PKH` is the only wallet not used by the `COOP Publisher` that belongs to the user. In fact, we need to hide this wallet from the `local-cluster` to emulate a real scenario:
306304

307305
```sh
308306
mv $WALLETS/signing-key-"$SUBMITTER_PKH".skey $WALLETS/my-signing-key-"$SUBMITTER_PKH".skey
@@ -314,7 +312,10 @@ The `make-exports` and `show-env` are provided Bash functions that wrap the pars
314312

315313
#### 4. Initializing the Protocol
316314

317-
We're ready now to perform the [COOP Plutus protocol genesis](coop-docs/02-plutus-protocol.md#protocol-genesis) using the `coop-pab-cli` command line tool. We prepare the working directory and run the cli:
315+
We're ready now to perform the [COOP Plutus protocol genesis](coop-docs/02-plutus-protocol.md#protocol-genesis)
316+
using the `coop-pab-cli` command line tool.
317+
We prepare the working directory and run the CLI.
318+
You can use Bash function `coop-genesis` to do the same:
318319

319320
```sh
320321
export COOP_PAB_DIR=.coop-pab-cli && mkdir $COOP_PAB_DIR
@@ -327,7 +328,7 @@ We should see confirmation the command executed successfully.
327328
[CONTRACT] [INFO [Any]] deployCoop: Finished
328329
```
329330
330-
At this point a `$COOP_PAB_DIR/coop-deployment.json` file was created that contains all the Plutus scripts associated with the `COOP Publisher`.
331+
At this point, a `$COOP_PAB_DIR/coop-deployment.json` file was created that contains all the Plutus scripts associated with the `COOP Publisher`.
331332
332333
> NOTE:
333334
> The `coop-deployment.json` file is intended to be shared with the users of the Protocol to enable them to assert proper script addresses and token authenticity.
@@ -372,15 +373,16 @@ getState: Success
372373
```
373374
374375
As we can see there's currently nothing of interest there.
375-
The `cs'certificates` contains a list of
376-
[Certificates](coop-docs/02-plutus-protocol.md#cert-validator) available in the
377-
Protocol, and the `cs'factStatements` contains a list of all the published [Fact
378-
Statements](coop-docs/02-plutus-protocol.md#fs-validator). `cs'currentTime` is
379-
included for convenience to observe the on-chain time.
376+
The `cs'certificates` list contains [Certificates](coop-docs/02-plutus-protocol.md#cert-validator)
377+
available in the Protocol,
378+
and the `cs'factStatements` contains a list of all the published
379+
[Fact Statements](coop-docs/02-plutus-protocol.md#fs-validator).
380+
`cs'currentTime` is included for convenience to observe the on-chain time.
380381
381382
Now, it's time to issue [Authentication
382383
tokens](coop-docs/02-plutus-protocol.md#auth-token) to [Authenticator
383-
wallets](coop-docs/02-plutus-protocol.md#authenticator):
384+
wallets](coop-docs/02-plutus-protocol.md#authenticator)
385+
(you can use Bash script `coop-mint-cert-redeemers`):
384386
385387
```sh
386388
coop-pab-cli mint-cert-redeemers \
@@ -395,7 +397,8 @@ CONTRACT] [INFO [Any]] mintCertR: Finished
395397
mintCertRdmrs: Minted $CERT-RDMR tokens with AssetClass
396398
```
397399
398-
We will now mint the certificate `$CERT` and authentication `$AUTH` tokens.
400+
We will now mint the certificate `$CERT` and authentication `$AUTH` tokens
401+
(Bash function `coop-mint-authentication`):
399402
400403
```sh
401404
NOW=$(get-onchain-time) && coop-pab-cli mint-auth \
@@ -423,15 +426,15 @@ The `coop-pab-cli mint-auth` is the most involved command in the protocol, it's
423426
intended to be used by the COOP Publisher operator on a regular basis to issue
424427
new 'ephemeral' [Authentication
425428
tokens](coop-docs/02-plutus-protocol.md#auth-token) that are used to
426-
authenticate publishing of each new Fact Statement. Once depleted, they have to
429+
authenticate the publishing of each new Fact Statement. Once depleted, they have to
427430
be replenished with this command and it's up to the Operator to manage when and
428431
how many are issued, a decision based on considering the security exposure of
429432
the [Authenticator wallets](coop-docs/02-plutus-protocol.md#authenticator) and
430433
the publishing request load.
431434
432435
The command takes in the [Authentication Authority
433436
wallet](coop-docs/02-plutus-protocol.md#authentication-authority) that
434-
authorizes the issuance of a new authentication tokens to an [Authenticator
437+
authorizes the issuance of new authentication tokens to an [Authenticator
435438
wallet](coop-docs/02-plutus-protocol.md#authenticator), setting the certificate
436439
validity to 1 HOUR from 'now', after which this authentication batch, meaning
437440
both [Certificates](coop-docs/02-plutus-protocol.md#cert-validator) and
@@ -442,10 +445,10 @@ become invalid and can be discarded.
442445
> Authentication tokens that are associated with an expired Certificate cannot be used in the Protocol.
443446
444447
Since all the [Authentication
445-
tokens](coop-docs/02-plutus-protocol.md#auth-token) are sent in batch to a
448+
tokens](coop-docs/02-plutus-protocol.md#auth-token) are sent in a batch to a
446449
single UTxO held by the [Authenticator
447450
wallets](coop-docs/02-plutus-protocol.md#authenticator) we provide a convenience
448-
utility to redistribute these tokens in separate UTxOs:
451+
utility to redistribute these tokens in separate UTxOs (Bash function `coop-redist-auth`):
449452
450453
```sh
451454
coop-pab-cli redistribute-auth --auth-wallet $AUTH_PKH
@@ -538,18 +541,22 @@ We're finally ready to run the first COOP service, namely the [TxBuilder
538541
gRPC](coop-proto/tx-builder-service.proto) back-end service that has the
539542
responsibility of building the COOP Cardano transactions:
540543
541-
```sh
542-
generate-keys $COOP_PAB_DIR
543-
coop-pab-cli tx-builder-grpc --auth-wallet $AUTH_PKH --fee-wallet $FEE_PKH
544-
```
545-
546544
The provided `generate-keys` Bash function will initialize the TLS keys and
547545
certificates used by the gRPC service. The service needs access to
548546
[Authenticator wallets](coop-docs/02-plutus-protocol.md#authenticator) as it
549547
provides signatures for the transactions, and a [Fee
550548
wallet](coop-docs/02-plutus-protocol.md#fee-collector) to send the service fees
551549
to.
552550
551+
```sh
552+
generate-keys $COOP_PAB_DIR
553+
```
554+
555+
Now we are ready to run the service (use Bash function `coop-run-tx-builder-grpc`):
556+
```sh
557+
coop-pab-cli tx-builder-grpc --auth-wallet $AUTH_PKH --fee-wallet $FEE_PKH
558+
```
559+
553560
> NOTE:
554561
> A [Fee wallet](coop-docs/02-plutus-protocol.md#fee-collector) is where the COOP Publisher receives the fees after a successful [Fact Statement Publishing](coop-docs/03-frontend-protocol.md).
555562
@@ -563,17 +570,21 @@ continue with the tutorial.
563570
564571
#### 6. Running a FactStatementStore gRPC service
565572
573+
> You can use Bash function `run-js-fs-store` to execute commands
574+
> described in this section.
575+
566576
COOP provides a low-scale implementation of the [FactStatementStore
567577
gRPC](coop-proto/fact-statement-store-service.proto) back-end service, namely
568578
the [JSON Fact Statement Store](coop-extras/json-fact-statement-store) that, as
569579
the name suggests, enables COOP Publisher operators to conveniently maintain a
570580
store of JSON encoded Fact Statements that users can refer to and eventually
571581
publish.
572582
573-
First let's prepare and initialize the service:
583+
First, let's prepare and initialize the service:
574584
575585
```sh
576586
export JS_STORE_DIR=.json-fs-store
587+
mkdir $JS_STORE_DIR
577588
sqlite3 -batch $JS_STORE_DIR/json-store.db ""
578589
json-fs-store-cli genesis --db $JS_STORE_DIR/json-store.db
579590
generate-keys $JS_STORE_DIR
@@ -603,6 +614,11 @@ Take a look at the values written by inspecting the fact statement store:
603614
604615
```sh
605616
echo "SELECT * FROM fact_statements" | sqlite3 $JS_STORE_DIR/json-store.db
617+
```
618+
619+
You expectedly should see:
620+
621+
```
606622
id1|["apples", "oranges", "pears"]
607623
id2|{"name": "Drazen Popovic", "age": 35}
608624
id3|"Lorem ipsum"
@@ -627,11 +643,11 @@ continue with the tutorial. We're almost there!
627643
The [Publisher gRPC](coop-proto/publisher-service.proto) is the principal
628644
fronted service that COOP users interact with as described in the [COOP Frontend
629645
protocol](coop-docs/03-frontend-protocol.md). This service relies on the
630-
back-end services that we've already setup, namely the [TxBuilder
646+
back-end services that we've already set up, namely the [TxBuilder
631647
gRPC](coop-proto/tx-builder-service.proto) service and the [FactStatementStore
632648
gRPC](coop-proto/fact-statement-store-service.proto) service.
633649
634-
It's straightforward to run:
650+
It's straightforward to run (you can use Bash function `run-publisher`):
635651
636652
```sh
637653
export COOP_PUBLISHER_DIR=.coop-publisher-cli
@@ -652,7 +668,7 @@ finally publish some fact statements.
652668
653669
#### 8. Publishing a Fact Statement
654670
655-
With the COOP Publisher fully set-up, we're ready to have our users publish some
671+
With the COOP Publisher fully set up, we're ready to have our users publish some
656672
Fact Statements (See[Publishing a Fact
657673
Statement](coop-docs/03-frontend-protocol.md#publishing-a-fact-statement)).
658674
@@ -670,7 +686,7 @@ Store`.
670686
> Each Fact Statement in a store should get their own unique identifier, but this responsibility falls under a concrete Fact Statement Store operator.
671687
672688
With that, we already know there are 3 Fact Statements in our Fact Statement
673-
Store we've set-up, namely `id1`, `id2` and `id3`. Let's publish all three of
689+
Store we've set up, namely `id1`, `id2`, and `id3`. Let's publish all three of
674690
these Fact Statements:
675691
676692
```sh
@@ -757,7 +773,7 @@ null
757773
```
758774
759775
The [Publisher gRPC](coop-proto/publisher-service.proto) service successfully
760-
serviced the request and returned a CBOR encoded Cardano transaction in the
776+
serviced the request and returned a CBOR-encoded Cardano transaction in the
761777
`mintFsTx` field of the response. Let's format the transaction so
762778
[cardano-cli](https://github.com/input-output-hk/cardano-node/tree/master/cardano-cli)
763779
can understand it:
@@ -770,7 +786,7 @@ echo "$RESP" | jq '.mintFsTx | .cborHex = .cborBase16 | del(.cborBase16) | .desc
770786
> NOTE:
771787
> Any Cardano wallet could be used as COOP provides a raw CBOR encoded transaction, we just used [cardano-cli](https://github.com/input-output-hk/cardano-node/tree/master/cardano-cli) for convenience to demonstrate the concept.
772788
773-
Finally we can sign the transaction:
789+
Finally, we can sign the transaction:
774790
775791
```sh
776792
cardano-cli transaction sign \
@@ -947,7 +963,7 @@ obsolete:
947963
```
948964
949965
The [Publisher gRPC](coop-proto/publisher-service.proto) service successfully
950-
serviced the request and returned a CBOR encoded Cardano transaction in the
966+
serviced the request and returned a CBOR-encoded Cardano transaction in the
951967
`gcFsTx` field of the response. Let's format the transaction so
952968
[cardano-cli](https://github.com/input-output-hk/cardano-node/tree/master/cardano-cli)
953969
can understand it, then sign and submit it:
@@ -980,11 +996,11 @@ We should see an empty list:
980996
[]
981997
```
982998
983-
As expected, there's no more Fact Statements available in the system.
999+
As expected, there are no more Fact Statements available in the system.
9841000
9851001
#### 10. Garbage collecting obsolete Certificate UTxOs
9861002
987-
The COOP Publisher operators can also manage reclaiming the [Min UTxO
1003+
The COOP Publisher operators can also manage the reclaiming of [Min UTxO
9881004
Ada](https://docs.cardano.org/native-tokens/minimum-ada-value-requirement) they
9891005
had to pay for each [Certificate
9901006
UTxO](coop-docs/02-plutus-protocol.md#cert-validator) they created when issuing
@@ -1065,7 +1081,7 @@ Garbage collection should complete successfully:
10651081
garbageCollect: Collected $CERT UTxOs from @CertV using $CERT-RDMR tokens
10661082
```
10671083
1068-
This is where [Certificate redeemer wallets](coop-docs/02-plutus-protocol.md#certificate-redeemer) come into play as they hold the tokens that the the verifying Plutus script checks when validating the consumption of its outputs.
1084+
This is where [Certificate redeemer wallets](coop-docs/02-plutus-protocol.md#certificate-redeemer) come into play as they hold the tokens that the verifying Plutus script checks when validating the consumption of its outputs.
10691085
10701086
```sh
10711087
coop-get-state

0 commit comments

Comments
 (0)