Skip to content
This repository was archived by the owner on Dec 2, 2024. It is now read-only.

Commit 404af7a

Browse files
authored
public testnet instructions (#83)
* public testnet instructions * wallet id * document pab-local-cluster * refine the note
1 parent 4e79fa9 commit 404af7a

File tree

6 files changed

+287
-3
lines changed

6 files changed

+287
-3
lines changed

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,8 @@ node.sock
109109
secrets/*/.gpg-id
110110
ghcid.txt
111111
plutus-pab/test-node/testnet/db
112+
plutus-pab/test-node/testnet/restore-wallet.json
112113
plutus-pab/test-node/alonzo-purple/db
113114
# profiling output files
114115
*.timelog
115116
*.stacks
116-
117-
# testnet configs
118-
testnet/

plutus-pab/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ $ nix-build ../default.nix -A plutus-apps.haskell.packages.plutus-pab
2828
## PAB Components
2929
PAB contains several commands and services, which are outlined below.
3030

31+
- [pab-local-cluster](#pab-local-cluster)
3132
- [psgenerator](#psgenerator)
3233
- [migrate](#migrate)
3334
- [all-servers](#all-servers)
@@ -38,6 +39,51 @@ PAB contains several commands and services, which are outlined below.
3839
- [chain-index](#chain-index)
3940
- [default-logging-config](#default-logging-config)
4041

42+
43+
### pab-local-cluster
44+
45+
#### Description
46+
47+
Can be used to run end-to-end tests using a private local testnet.
48+
49+
#### Example
50+
51+
1. Build necessary components:
52+
53+
```
54+
> cabal build plutus-pab-local-cluster cardano-node cardano-wallet
55+
```
56+
57+
2. Get config data:
58+
59+
Clone <https://github.com/input-output-hk/cardano-wallet/> to $DIR and set the
60+
`SHELLEY_TEST_DATA` environment variable:
61+
62+
```
63+
export SHELLEY_TEST_DATA=$DIR/lib/shelley/test/data/cardano-node-shelley
64+
```
65+
66+
3. Run the local cluster:
67+
68+
```
69+
> cabal exec plutus-pab-local-cluster
70+
```
71+
72+
4. Wait until the message `Starting PAB backend server on port 9080` appears.
73+
74+
5. Run the integration test:
75+
76+
```
77+
curl -H "Content-Type: application/json" -v \
78+
-X POST \
79+
-d '{"caID":{"tag":"IntegrationTest"},"caWallet":{"getWalletId":"2d4cc31a4b3116ab86bfe529d30d9c362acd0b44"}}' \
80+
localhost:9080/api/contract/activate
81+
```
82+
83+
A couple of log messages appear, the last one should say something like "Tx
84+
confirmed. Integration test complete."
85+
86+
4187
### psgenerator
4288

4389
```

plutus-pab/test-node/README.md

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
## Instructions for running a public testnet end-to-end integration test
2+
3+
What follows is a series of steps to demonstrate running an end-to-end
4+
integration test of the PAB on the public testnet.
5+
6+
#### Process
7+
8+
Assumptions:
9+
10+
- You have the `plutus-apps` repo checked out at `$PLUTUS`
11+
- You have [jq](https://stedolan.github.io/jq/)
12+
- You have a few hours to wait for everything to sync (the first time.)
13+
14+
Steps:
15+
16+
You will need ~6 terminals to run all the different components.
17+
18+
19+
1. Build all the necessary components:
20+
21+
```
22+
> cd $PLUTUS
23+
> cabal build plutus-pab-examples plutus-chain-index cardano-node cardano-wallet
24+
```
25+
26+
2. Start the testnet node locally:
27+
28+
```
29+
> cd $PLUTUS/plutus-pab/test-node/
30+
> ./start-testnet-node.sh
31+
```
32+
33+
Note: It's important that this is done from the specific directory, because
34+
the config paths are relative.
35+
36+
3. Run the cardano wallet backend:
37+
38+
```
39+
> cd $PLUTUS/plutus-pab/test-node/
40+
> cabal exec -- cardano-wallet serve \
41+
--testnet testnet/testnet-byron-genesis.json \
42+
--node-socket testnet/node.sock
43+
```
44+
45+
4. Create or restore a public testnet wallet:
46+
47+
Here you have a few options. You can re-use an existing wallet, or create
48+
one.
49+
50+
**Create a new wallet**
51+
52+
- Generate a recovery phrase:
53+
54+
```
55+
> cabal exec -- cardano-wallet recovery-phrase generate
56+
```
57+
58+
- Save this in a file named `restore-wallet.json` in the `testnet` folder:
59+
60+
```
61+
> cd $PLUTUS/plutus-pab/test-node/
62+
> cat testnet/restore-wallet.json
63+
{ "name": "PAB testing wallet"
64+
, "mnemonic_sentence": ["word1", "word2", ...]
65+
, "passphrase": "pab123456789"
66+
}
67+
```
68+
69+
- Load the wallet:
70+
71+
```
72+
> cd $PLUTUS/plutus-pab/test-node/
73+
> curl -H "content-type: application/json" -XPOST \
74+
-d @testnet/restore-wallet.json \
75+
localhost:8090/v2/wallets
76+
```
77+
78+
Then, take note of the Wallet ID that is created, and save that:
79+
80+
```
81+
> export WALLET_ID=...
82+
```
83+
84+
- Put some tAda in it, by first obtaining an address:
85+
86+
```
87+
> curl -H "content-type: application/json" \
88+
-XGET localhost:8090/v2/wallets/$WALLET_ID/addresses | jq '.'
89+
```
90+
91+
(Any address will do.)
92+
93+
- Then, navigate over to the [tesnet
94+
faucet](https://testnets.cardano.org/en/testnets/cardano/tools/faucet/) and
95+
send it some tAda.
96+
97+
You can verify that the transfer has taken place by clicking the link the
98+
faucet application gives you; you see a transaction like so:
99+
100+
![](faucet-example.png)
101+
102+
5. Start the chain index:
103+
104+
```
105+
> cd $PLUTUS/plutus-pab/test-node/
106+
> cabal exec -- plutus-chain-index --config testnet/chain-index-config.json start-index
107+
```
108+
109+
6. Start the PAB:
110+
111+
If it's the first time your running, you'll need to ask the PAB to make the
112+
database:
113+
114+
```
115+
> cd $PLUTUS/plutus-pab/test-node/
116+
> cabal exec -- plutus-pab-examples \
117+
--config testnet/pab-config.yml migrate
118+
```
119+
120+
Then, run the PAB
121+
122+
```
123+
> cd $PLUTUS/plutus-pab/test-node/
124+
> cabal exec -- plutus-pab-examples \
125+
--config testnet/pab-config.yml webserver \
126+
--passphrase pab123456789
127+
```
128+
129+
7. Wait for all chain clients (`cardano-node`, `cardano-wallet`,
130+
`plutus-pab-examples`, `plutus-chain-index`) to fully synchronise with the testnet.
131+
132+
On my computer, the wallet takes about 1 hour, and the chain index takes
133+
about 3 hours.
134+
135+
You can check what slot it needs to get up to by checking [the testnet
136+
explorer](https://explorer.cardano-testnet.iohkdev.io/en); and you can query
137+
the status of the chain index like so:
138+
139+
```
140+
> curl -s localhost:9083/tip | jq '.tipSlot.getSlot'
141+
```
142+
143+
When it's fully synced the slot should be the same slot that the
144+
plutus-pab-examples process last printed to the console. Note that the PAB
145+
process will be silent for a while, after the initial log messages, before
146+
it starts printing log messages about its sync status. **You _must_ wait**
147+
for the PAB to start printing messages like:
148+
149+
```
150+
...
151+
Current block: 327295. Current slot: 41749136.
152+
Current block: 327295. Current slot: 41749150.
153+
```
154+
155+
before running the next step. (In fact, it's okay not to wait, and it will
156+
complete eventually; but if you want to see it live, then wait.)
157+
158+
159+
8. **Start the integration test**
160+
161+
```
162+
> curl -H "Content-Type: application/json" -v -X POST -d \
163+
"{\"caID\":{\"tag\":\"IntegrationTest\"},\"caWallet\":{\"getWalletId\":\"$WALLET_ID\"}}" \
164+
localhost:9080/api/contract/activate
165+
```
166+
167+
9. Wait for the integration test to finish.
168+
169+
There will be a message like `"Tx confirmed. Integration test complete."`
170+
printed from the console running the pab.
171+
172+
That's it!
32.4 KB
Loading
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"cicSlotConfig": {
3+
"scSlotLength": 1000,
4+
"scSlotZeroTime": 1591566291000
5+
},
6+
"cicPort": 9083,
7+
"cicSecurityParam": 2160,
8+
"cicSocketPath": "testnet/node.sock",
9+
"cicDbPath": "/tmp/chain-index.db",
10+
"cicNetworkId": {
11+
"contents": {
12+
"unNetworkMagic": 1097911063
13+
},
14+
"tag": "Testnet"
15+
}
16+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
dbConfig:
2+
dbConfigFile: plutus-pab.db
3+
dbConfigPoolSize: 20
4+
5+
pabWebserverConfig:
6+
baseUrl: http://localhost:9080
7+
staticDir: plutus-pab-client/dist
8+
permissiveCorsPolicy: False
9+
# Optional timeout (in seconds) for calls to endpoints that are not currently
10+
# available. If this is not set, calls to unavailable endpoints fail
11+
# immediately.
12+
endpointTimeout: 5
13+
14+
walletServerConfig:
15+
baseUrl: http://localhost:8090
16+
wallet:
17+
getWallet: 1
18+
19+
nodeServerConfig:
20+
mscSocketPath: testnet/node.sock
21+
mscBaseUrl: "localhost"
22+
mscKeptBlocks: 2160
23+
mscNetworkId: "1097911063" # Testnet network ID (main net = empty string)
24+
mscSlotConfig:
25+
scSlotZeroTime: 1591566291000 # Wednesday, July 29, 2020 21:44:51 - shelley launch time in milliseconds
26+
scSlotLength: 1000 # In milliseconds
27+
mscFeeConfig:
28+
fcConstantFee:
29+
getLovelace: 10 # Constant fee per transaction in lovelace
30+
fcScriptsFeeFactor: 1.0 # Factor by which to multiply size-dependent scripts fee in lovelace
31+
mscInitialTxWallets: []
32+
mscNodeMode: AlonzoNode
33+
34+
chainIndexConfig:
35+
ciBaseUrl: http://localhost:9083
36+
ciWatchedAddresses: []
37+
38+
requestProcessingConfig:
39+
requestProcessingInterval: 1
40+
41+
signingProcessConfig:
42+
spBaseUrl: http://localhost:9084
43+
spWallet:
44+
getWallet: 1
45+
46+
metadataServerConfig:
47+
mdBaseUrl: http://localhost:9085
48+
49+
# Optional EKG Server Config
50+
# ----
51+
# monitoringConfig:
52+
# monitoringPort: 9090

0 commit comments

Comments
 (0)