Skip to content

Commit 02943b6

Browse files
committed
Include UTxO HD installation/usage instructions in READMEs
* Added installation/usage instructions for UTxO HD to top-level README, installation instructions, and node config file instructions. * More documentation for `defaultLMDBLimits`. * Other change: Parsing behaviour for LMDB mapsize should now allow parsing more types of units. The previous parsing behaviour would only parse 1024-based units such Mebibytes, Gibibytes, etc. Now, we can also provide 1000-based units, for example. * Fixed Redhat/Fedora/CentOS installation instructions, which was missing an instruction to install OpenSSL libraries, amongst others. * Crudely updated the Windows installation instructions.
1 parent 920dc37 commit 02943b6

File tree

7 files changed

+96
-37
lines changed

7 files changed

+96
-37
lines changed

README.rst

+8
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ The general synopsis is as follows:
9898
[--host-ipv6-addr IPV6-ADDRESS]
9999
[--port PORT]
100100
[--config NODE-CONFIGURATION] [--validate-db]
101+
[ --in-memory-ledger-db-backend | --lmdb-ledger-db-backend [--lmdb-mapsize BIN]]
102+
101103
Run the node.
102104
103105
* ``--topology`` - Filepath to a topology file describing which peers the node should connect to.
@@ -128,6 +130,12 @@ The general synopsis is as follows:
128130

129131
* ``--validate-db`` - Flag to revalidate all on-disk database files
130132

133+
* ``--in-memory-ledger-db-backend`` - Optionally use the in-memory backend of the UTxO HD feature: store the complete ledger state in memory. Incompatible with ``--lmdb-ledger-db-backend``.
134+
135+
* ``--lmdb-ledger-db-backend`` - Optionally use the LMDB backend of the UTxO HD feature: store parts of the ledger state on disk. Incompatible with ``--in-memory-ledger-db-backend``. The node uses the LMDB backend by default if no ``--*-db-backend`` flags are set.
136+
137+
* ``--lmdb-mapsize`` - Optionally set the mapsize (maximum database size) for the LMDB backend. By default, the mapsize (maximum database size) of the backend is set to 16 Gigabytes. Warning: if the database size exceeds the given mapsize, the node will abort. Therefore, the mapsize should be set to a value high enough to guarantee that the maximum database size will not be reached during the expected node uptime.
138+
131139
Configuration ``.yaml`` files
132140
=============================
133141

cardano-node/src/Cardano/Node/Configuration/LedgerDB.hs

+24
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ data BackingStoreSelectorFlag =
2828

2929
-- | Recommended settings for the LMDB backing store.
3030
--
31+
-- === @'lmdbMapSize'@
3132
-- The default @'LMDBLimits'@ uses an @'lmdbMapSize'@ of @16_000_000_000@
3233
-- bytes, or 16 GigaBytes. @'lmdbMapSize'@ sets the size of the memory map
3334
-- that is used internally by the LMDB backing store, and is also the
@@ -42,6 +43,29 @@ data BackingStoreSelectorFlag =
4243
-- @'lmdbMapSize'@. If this fatal error were to occur, we would expect that
4344
-- the node can continue normal operation if it is restarted with a higher
4445
-- @'lmdbMapSize'@ configured. Nonetheless, this situation should be avoided.
46+
--
47+
-- === @'lmdbMaxDatabases'@
48+
-- The @'lmdbMaxDatabases'@ is set to 10, which means that the LMDB backing
49+
-- store will allow up @<= 10@ internal databases. We say /internal/
50+
-- databases, since they are not exposed outside the backing store interface,
51+
-- such that from the outside view there is just one /logical/ database.
52+
-- Two of these internal databases are reserved for normal operation of the
53+
-- backing store, while the remaining databases will be used to store ledger
54+
-- tables. At the moment, there is at most one ledger table that will be
55+
-- stored in an internal database: the UTxO. Nonetheless, we set
56+
-- @'lmdbMaxDatabases'@ to @10@ in order to future-proof these limits.
57+
--
58+
-- === @'lmdbMaxReaders'@
59+
-- The @'lmdbMaxReaders'@ limit sets the maximum number of threads that can
60+
-- read from the LMDB database. Currently, there should only be a single reader
61+
-- active. Again, we set @'lmdbMaxReaders'@ to @16@ in order to future-proof
62+
-- these limits.
63+
--
64+
-- === References
65+
-- For more information about LMDB limits, one should inspect:
66+
-- * The @lmdb-simple@ and @haskell-lmdb@ forked repositories.
67+
-- * The official LMDB API documentation at
68+
-- <http://www.lmdb.tech/doc/group__mdb.html>.
4569
defaultLMDBLimits :: LMDBLimits
4670
defaultLMDBLimits = LMDBLimits {
4771
lmdbMapSize = 16_000_000_000

cardano-node/src/Cardano/Node/Configuration/POM.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ instance FromJSON PartialNodeConfiguration where
331331
maybeMapSize :: Maybe String <- v .:? "LMDBMapSize"
332332
mapSize <- case maybeMapSize of
333333
Nothing -> return Nothing
334-
Just s -> case parseValue ParseBinary s of
334+
Just s -> case parseValue ParseExact s of
335335
Left e -> fail ("Malformed LMDBMapSize: " <> e)
336336
Right units -> return $ Just units
337337
return . Just . LMDB $ mapSize

cardano-node/src/Cardano/Node/Parsers.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ parseLedgerDBBackend = parseInMemory <|> parseLMDB <*> optional parseMapSize
240240

241241
parseMapSize :: Parser Int
242242
parseMapSize =
243-
option (eitherReader (parseValue ParseBinary)) (
243+
option (eitherReader (parseValue ParseExact)) (
244244
long "lmdb-mapsize"
245245
<> metavar "BIN"
246246
<> help "The maximum database size defined as a binary \
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,52 @@
11
# Building the development version of the Cardano node on Windows
22

3-
This document explains how to build a __DEVELOPMENT__ version of the `cardano-node`.
4-
Note that this is *not* for building a __PRODUCTION__ version of the node.
3+
This document explains how to build a __DEVELOPMENT__ version of the `cardano-node`. Note that this is *not* for building a __PRODUCTION__ version of the node.
54

6-
To start building on `Windows`, you will need to install and configure specific tools outlined below. We recommend using [chocolatey](https://chocolatey.org), which provides the `choco` command to install these tools.
5+
We recommend installing and using `git-bash` for development purposes, which is `git` when installed with `choco install git`.
76

8-
You can run all the instructions that invoke `choco` in PowerShell with root privileges. We recommend installing and using `git-bash` for development purposes, which is `git` when installed with `choco install git`.
97

10-
## Install GHC
8+
## Install the Haskell environment
119

12-
The recommended way is to run the following command in PowerShell:
10+
The recommended way to install the Haskell tools is via [GHCup](https://www.haskell.org/ghcup/). Check [this page](https://www.haskell.org/ghcup/install/) for further explanation on the installation process.
1311

14-
```PowerShell
15-
choco install --version 8.10.7 ghc
12+
Once GHCup is installed, open a new terminal (to get an updated environment) and run:
13+
14+
```bash
15+
ghcup install ghc 8.10.7
16+
ghcup install cabal 3.6.2.0
17+
ghcup set ghc 8.10.7
18+
ghcup set cabal 3.6.2.0
1619
```
1720

21+
Alternatively, with `ghcup tui` you can pick the specific versions of the tools that you want to install, in particular you should have installed and set:
22+
- `cabal >= 3.6.2.0`
23+
- `GHC >= 8.10.7`
24+
1825
## Install pkg-config
1926

20-
```PowerShell
27+
To start building on `Windows`, you will need to install and configure specific tools outlined below. We recommend using [chocolatey](https://chocolatey.org), which provides the `choco` command to install some of these tools. You can run all the instructions that invoke `choco` in bash with root privileges.
28+
29+
```bash
2130
choco install pkgconfiglite
2231
```
2332

2433
## Install vcpkg
2534

26-
You will first need to install `vcpkg` to proceed with `libsodium` library installation (which is the next step).
35+
You will first need to install `vcpkg` to proceed installing necessary libraries (which is the next step).
2736

28-
For this, use `git`(which you can also install using `choco`) and follow [these
29-
instructions](https://github.com/microsoft/vcpkg#quick-start-windows).
37+
For this, use `git`(which you can also install using `choco`) and follow [these instructions](https://github.com/microsoft/vcpkg#quick-start-windows).
3038

31-
You can now install `libsodium` with the following command:
39+
You can now install `libsodium`, `openssl`, `secp256k1` and `lmdb` with the following commands:
3240
```bash
3341
./vcpkg install --triplet x64-windows libsodium
42+
./vcpkg install --triplet x64-mingw-dynamic openssl
43+
./vcpkg install secp256k1
44+
./vcpkg install lmdb
3445
```
3546

36-
## Create libsodium.pc file
47+
## Create libsodium.pc file (and others)
3748

38-
To find system dependencies like `libsodium`, `cabal` uses `pkg-config`. On Windows, you will need to create the `libsodium.pc` description file in a correct
39-
directory.
49+
To find system dependencies like `libsodium`, `cabal` uses `pkg-config`. On Windows, you will need to create the `libsodium.pc` description file in a correct directory.
4050

4151
In one of the paths reported by:
4252
```bash
@@ -54,20 +64,22 @@ Description: libsodium library
5464
Cflags: -I${includedir}/sodium
5565
Libs: -L${libdir} -llibsodium
5666
```
57-
> Note that you need to replace `VCPKG_PATH` with the
58-
absolute path, where you use `vcpkg`, and `LIBSODIUM_VERSION` with the version
59-
number of `libsodium` which was installed on your system. Please verify that
60-
the paths above contain
61-
`libsodium.dll` file and headers.
67+
> Note that you need to replace `VCPKG_PATH` with the absolute path, where you use `vcpkg`, and `LIBSODIUM_VERSION` with the version number of `libsodium` which was installed on your system. Please verify that the paths above contain `libsodium.dll` file and headers.
68+
69+
> Also, you cannot use `prefix=` in the `libsodium.pc` file. This might be changed for some other directory, `pkg-config` provides a switch to use the provided `prefix`, but there is no way to instruct `cabal` to do so.
70+
71+
Follow the same procedure of creating `.pc` files for `openssl`, `secp256k1` and `lmdb`.
72+
73+
Finally, ensure that
74+
```
75+
pkg-config --list-all
76+
```
77+
lists all packages: `libsodium`, `openssl`, `secp256k1` and `lmdb`.
6278

63-
> Also, you cannot use `prefix=` in the `libsodium.pc` file. This might be changed for
64-
some other directory, `pkg-config` provides a switch to use the provided
65-
`prefix`, but there is no way to instruct `cabal` to do so.
6679

6780
## `cabal` configuration
6881

69-
Go to the directory, where you cloned the `cardano-node` repository and add the command below
70-
to your `cabal.project.local` file (if you don't already have it, create one):
82+
Go to the directory, where you cloned the `cardano-node` repository and add the command below to your `cabal.project.local` file (if you don't already have it, create one):
7183

7284
```
7385
max-backjump: 5000
@@ -80,8 +92,7 @@ extra-lib-dirs: "VCPKG_PATH\\installed\\x64-windows\\bin"
8092
extra-include-dirs: "VCPKG_PATH\\installed\\x64-windows\\include"
8193
```
8294

83-
The final step is to add `VCPKG_PATH/installed/x64-windows/bin` to the `PATH`
84-
variable. Since we are using `git-bash`, you can do this with:
95+
The final step is to add `VCPKG_PATH/installed/x64-windows/bin` to the `PATH` variable. Since we are using `git-bash`, you can do this with:
8596

8697
```
8798
export PATH="VCPKG_PATH/installed/x64-windows/bin:${PATH}"
@@ -93,12 +104,10 @@ You can now build the node with:
93104
```bash
94105
cabal build --builddir /c/dist exe:cardano-node
95106
```
96-
> Note: using `--builddir /c/dist` with a succinct directory protects you
97-
from exceeding the [maximal path
98-
size](https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation)
99-
on Windows (which is a limitation of the linker rather than `ghc` itself).
100107

101-
You can now verify whether the node runs:
108+
> Note: using `--builddir /c/dist` with a succinct directory protects you from exceeding the [maximal path size](https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation) on Windows (which is a limitation of the linker rather than `ghc` itself).
109+
110+
You can now verify whether the node runs:
102111
```bash
103112
cabal run --builddir /c/dist exe:cardano-node -- run --help
104113
```

doc/getting-started/install.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ To download the source code and build it, you need the following packages and to
2727
* developer libraries for `systemd`,
2828
* developer libraries for `ncurses`,
2929
* `ncurses` compatibility libraries,
30+
* developer libraries for `openssl`,
31+
* developer libraries for `lmdb`,
3032
* the Haskell build tool `cabal`,
3133
* the GHC Haskell compiler (version `8.10.7` or above).
3234

@@ -35,14 +37,14 @@ In Redhat, Fedora, and Centos:
3537
```bash
3638
sudo yum update -y
3739
sudo yum install git gcc gcc-c++ tmux gmp-devel make tar xz wget zlib-devel libtool autoconf -y
38-
sudo yum install systemd-devel ncurses-devel ncurses-compat-libs -y
40+
sudo yum install systemd-devel ncurses-devel ncurses-compat-libs which jq openssl-devel lmdb-devel -y
3941
```
4042

4143
For Debian/Ubuntu, use the following instead:
4244

4345
```bash
4446
sudo apt-get update -y
45-
sudo apt-get install automake build-essential pkg-config libffi-dev libgmp-dev libssl-dev libtinfo-dev libsystemd-dev zlib1g-dev make g++ tmux git jq wget libncursesw5 libtool autoconf -y
47+
sudo apt-get install automake build-essential pkg-config libffi-dev libgmp-dev libssl-dev libtinfo-dev libsystemd-dev zlib1g-dev make g++ tmux git jq wget libncursesw5 libtool autoconf liblmdb-dev -y
4648
```
4749

4850
If you are using a different flavor of Linux, you will need to use the correct package manager for your platform instead of `yum` or `apt-get`, and the names of the packages you need to install might differ. On MacOSX, use the Homebrew (`brew`) installer.

doc/getting-started/understanding-config-files.md

+16
Original file line numberDiff line numberDiff line change
@@ -355,3 +355,19 @@ It is also possible to have more fine grained control over filtering of trace ou
355355
}
356356
}
357357
```
358+
359+
#### UTxO HD
360+
361+
The UTxO HD feature of the consensus layer allows parts of the ledger state to be stored on-disk, whereas consensus previously kept the whole ledger state in memory. The node can be configured to use any of two *backends*:
362+
363+
* The *LMDB backend*, which is built around a Lightning Memory-Mapped Database (LMDB), stores parts of the ledger state on disk. Optionally, a configuration can be included that sets the mapsize (maximum size) of the on-disk database that is used to store parts of the ledger state. By default, the mapsize is set to 16 Gigabytes. **Warning**: if the database size exceeds the given mapsize, the node will abort. Therefore, the mapsize should be set to a value high enough to guarantee that the maximum database size will not be reached during the expected node uptime.
364+
```json
365+
"LedgerDBBackend": "LMDB",
366+
"LMDBMapSize": "16G",
367+
```
368+
* The *InMemory backend* stores parts of the ledger state in memory.
369+
```json
370+
"LedgerDBBackend": "InMemory",
371+
```
372+
373+
If no choice of backend is configured, then the node defaults to using the LMDB backend with the *default* mapsize. It is recommended not to opt for the in-memory backend if the machine that is running the node is constrained by the amount of available memory.

0 commit comments

Comments
 (0)