@@ -9,64 +9,97 @@ the memory overhead.
9
9
In order to be able to use the tool we need to get ahold of current ledger
10
10
state. For this we need to start a cardano node and wait for it to sync.
11
11
12
- ``` haskell
13
- $ export CARDANO_DATA = " ${HOME}/iohk/chain/mainnet"
14
- $ mkdir - p " ${CARDANO_DATA}" / db
12
+ ``` shell
13
+ $ export CARDANO_DATA=${HOME} /iohk/chain/mainnet
14
+ $ mkdir -p " ${CARDANO_DATA} /db"
15
15
$ cd " ${CARDANO_DATA} "
16
16
```
17
17
18
- Download all the [ mainnet related config files] ( https://developers.cardano.org/docs/get-started/running-cardano/#mainnet--production ) :
18
+ Download all the [ mainnet related config files] ( https://developers.cardano.org/docs/get-started/cardano-node/running-cardano/#configuration-files ) :
19
+
20
+ ``` shell
21
+ curl -O -J https://book.play.dev.cardano.org/environments/mainnet/config.json
22
+ curl -O -J https://book.play.dev.cardano.org/environments/mainnet/db-sync-config.json
23
+ curl -O -J https://book.play.dev.cardano.org/environments/mainnet/submit-api-config.json
24
+ curl -O -J https://book.play.dev.cardano.org/environments/mainnet/topology.json
25
+ curl -O -J https://book.play.dev.cardano.org/environments/mainnet/byron-genesis.json
26
+ curl -O -J https://book.play.dev.cardano.org/environments/mainnet/shelley-genesis.json
27
+ curl -O -J https://book.play.dev.cardano.org/environments/mainnet/alonzo-genesis.json
28
+ curl -O -J https://book.play.dev.cardano.org/environments/mainnet/conway-genesis.json
19
29
```
20
- curl -O -J https://hydra.iohk.io/build/7370192/download/1/mainnet-config.json
21
- curl -O -J https://hydra.iohk.io/build/7370192/download/1/mainnet-byron-genesis.json
22
- curl -O -J https://hydra.iohk.io/build/7370192/download/1/mainnet-shelley-genesis.json
23
- curl -O -J https://hydra.iohk.io/build/7370192/download/1/mainnet-alonzo-genesis.json
24
- curl -O -J https://hydra.iohk.io/build/7370192/download/1/mainnet-topology.json
30
+
31
+ Download or build copies of ` cardano-node ` and ` cardano-cli ` . A convenient way of doing this is to download the assets from one of the ` cardano-node ` [ releases] ( https://github.com/IntersectMBO/cardano-node/releases ) on GitHub. The Linux executables are statically linked, so will run on any system.
32
+
25
33
```
26
34
27
35
Start the node and wait for it to fully sync
28
36
29
- ```
37
+ ```shell
30
38
$ export CARDANO_NODE_SOCKET_PATH="${CARDANO_DATA}/db/node.socket"
31
- $ cardano-node run
32
- --topology "${CARDANO_DATA}/mainnet- topology.json" \
33
- --database-path "${CARDANO_DATA}/db " \
34
- --socket -path "${CARDANO_NODE_SOCKET_PATH} " \
35
- --host-addr 127.0.0.1 \
36
- --port 3001 \
37
- --config "${CARDANO_DATA}/mainnet-config.json" &
39
+ $ cardano-node run \
40
+ --topology "${CARDANO_DATA}/topology.json" \
41
+ --config "${CARDANO_DATA}/config.json " \
42
+ --database -path "${CARDANO_DATA}/db " \
43
+ --socket-path "${CARDANO_NODE_SOCKET_PATH}" \
44
+ --host-addr 0.0.0.0 \
45
+ --port 3001 &
38
46
```
39
47
40
- Dump the ledger state and focus back onto the node:
48
+ Dump the ledger state:
49
+
50
+ ``` shell
51
+ $ cardano-cli query ledger-state --mainnet \
52
+ --socket-path " ${CARDANO_NODE_SOCKET_PATH} " \
53
+ --out-file " ${CARDANO_DATA} /new-epoch-state.bin"
54
+ ```
55
+
56
+ Bring the node back into the foreground and use Ctrl-C to stop it:
41
57
42
58
``` shell
43
- $ cardano-cli query ledger-state --mainnet --out-file " ${CARDANO_DATA} /ledger-state.bin"
44
59
$ fg
60
+ $ ^C
45
61
```
46
- Hit Ctr-C to stop the node
47
62
48
- ## Populate sqlite db
63
+ ## Populate sqlite db from ` NewEpochState ` file
49
64
50
65
``` shell
51
- $ cabal run -- ledger-state:ledger-state --new-epoch-state-cbor=" ${CARDANO_DATA} /ledger-state.bin" --sqlite-db=" ${CARDANO_DATA} /ledger-state.sqlite"
66
+ $ cabal run -- ledger-state:ledger-state \
67
+ --new-epoch-state-cbor=" ${CARDANO_DATA} /new-epoch-state.bin" \
68
+ --sqlite-db=" ${CARDANO_DATA} /epoch-state.sqlite"
52
69
```
53
70
54
- ## Create NewEpochState from sqlite db
71
+ ## Create ` EpochState ` file from sqlite db
55
72
56
73
``` shell
57
- $ cabal run -- ledger-state:ledger-state --epoch-state-cbor=" ${CARDANO_DATA} /ledger-state.bin" --sqlite-db=" ${CARDANO_DATA} /ledger-state.sqlite"
74
+ $ cabal run -- ledger-state:ledger-state \
75
+ --epoch-state-cbor=" ${CARDANO_DATA} /epoch-state.bin" \
76
+ --sqlite-db=" ${CARDANO_DATA} /epoch-state.sqlite"
58
77
```
59
78
60
79
## Running benchmarks
61
80
62
81
### Memory
63
82
64
83
``` shell
65
- $ cabal bench ledger-state:memory --benchmark-options=" --new-epoch-state-cbor=\" ${CARDANO_DATA} /ledger-state.bin\" --new-epoch-state-sqlite=\" ${CARDANO_DATA} /ledger-state.sqlite\" "
84
+ $ cabal build ledger-state:memory
85
+ $ cabal bench ledger-state:memory -v0 \
86
+ --benchmark-option=" --new-epoch-state-cbor=${CARDANO_DATA} /new-epoch-state.bin" \
87
+ --benchmark-option=" --epoch-state-cbor=${CARDANO_DATA} /epoch-state.bin" \
88
+ --benchmark-option=" --sqlite-db=${CARDANO_DATA} /epoch-state.sqlite" |
89
+ tee ledger-state:memory.txt
66
90
```
67
91
### Performance
68
92
69
93
Performance benchmarks need an actual mainnet ledger state and genesis config
70
94
file to run properly. It is not possible to add extra arguments to criterion cli
71
95
menu, therefore paths to those files must be supplied as environment variables.
72
96
97
+ ``` shell
98
+ $ export BENCH_GENESIS_PATH=${CARDANO_DATA} /shelley-genesis.json
99
+ $ export BENCH_LEDGER_STATE_PATH=${CARDANO_DATA} /new-epoch-state.bin
100
+ $ cabal bench ledger-state:performance --benchmark-option=--csv=ledger-state:performance.csv
101
+ ```
102
+
103
+ The csv file will be saved in the ` libs/ledger-state ` directory.
104
+
105
+ Since the ` performance ` benchmark uses only ` new-epoch-state.bin ` you don't need to run the ` sqlite.db ` steps above if you want to run only the ` performance ` benchmark.
0 commit comments