Skip to content

Commit 95cc3a8

Browse files
committed
UTXO-HD 10.2
1 parent b998c34 commit 95cc3a8

File tree

37 files changed

+1261
-389
lines changed

37 files changed

+1261
-389
lines changed

.github/workflows/haskell.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,19 @@ jobs:
9797
with:
9898
use-sodium-vrf: true # default is true
9999

100+
- name: Linux install lmdb
101+
if: matrix.sys.os == 'ubuntu-latest'
102+
run: sudo apt install liblmdb-dev
103+
104+
- name: Mac install lmdb
105+
if: matrix.sys.os == 'macos-13'
106+
run: brew install lmdb
107+
108+
- name: Windows install lmdb
109+
if: matrix.sys.os == 'windows-latest'
110+
shell: 'C:/msys64/usr/bin/bash.exe -e {0}'
111+
run: /usr/bin/pacman --noconfirm -S mingw-w64-x86_64-lmdb
112+
100113
- uses: actions/checkout@v4
101114

102115
- name: Cabal update

.gitignore

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
/cabal.project.old
88
configuration/defaults/simpleview/genesis/
99
configuration/defaults/liveview/genesis/
10-
dist-newstyle
11-
dist-newstyle/
12-
dist-profiled/
10+
dist-*
1311
dist/
1412
*~
1513
\#*
@@ -20,12 +18,13 @@ dist/
2018
result*
2119
/launch-*
2220
stack.yaml.lock
21+
.ghcid
2322

2423
/.cache
2524
/db
2625
/db-[0-9]
2726
/logs
28-
/mainnet
27+
/mainnet*
2928
/profile
3029
/launch_*
3130
/state-*

cabal.project

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ repository cardano-haskell-packages
1313
-- See CONTRIBUTING for information about these, including some Nix commands
1414
-- you need to run if you change them
1515
index-state:
16-
, hackage.haskell.org 2024-12-24T12:56:48Z
16+
, hackage.haskell.org 2024-12-31T10:16:13Z
1717
, cardano-haskell-packages 2025-01-08T16:35:32Z
1818

1919
packages:
@@ -71,18 +71,77 @@ allow-newer:
7171
-- Do NOT add more source-repository-package stanzas here unless they are strictly
7272
-- temporary! Please read the section in CONTRIBUTING about updating dependencies.
7373

74+
-- UTxO-HD for 10.2
75+
source-repository-package
76+
type: git
77+
location: https://github.com/IntersectMBO/ouroboros-consensus.git
78+
tag: 54ac1b2f5bd15f3f0f70e9f4a9ebf3e34792dcf2
79+
--sha256: sha256-PdzKg4PA6DnzhRVUF2kiBfvf8S+ekXmws73XDXSZdnY=
80+
subdir:
81+
ouroboros-consensus
82+
ouroboros-consensus-cardano
83+
ouroboros-consensus-diffusion
84+
ouroboros-consensus-protocol
85+
sop-extras
86+
strict-sop-core
87+
88+
-- UTxO-HD for 10.2
7489
source-repository-package
7590
type: git
7691
location: https://github.com/IntersectMBO/cardano-api.git
77-
tag: f93b1cf1b5f2649e14c42f70a948ca9c2e5edc70
78-
--sha256: sha256-4+x6GSAJpOUzVuGEuMztdmG5+sSH3uym99YAH6a0Az0=
92+
tag: e3b7712d80fe5721bccf5dccb89e626de12ae419
93+
--sha256: sha256-Z2/qzlS4JfAtdSOc/V0r3wfbfOq6YWAobgmKKzlesdM=
7994
subdir:
8095
cardano-api
8196

97+
-- UTxO-HD for 10.2
8298
source-repository-package
8399
type: git
84100
location: https://github.com/IntersectMBO/cardano-cli.git
85-
tag: abb632ccf5887d53b33fc20283a2c4180b0ecd92
86-
--sha256: sha256-WSI5zsVON99O9Elm2xqB05KCLHHjgf3Fw6nejdTyMAs=
101+
tag: e3b99e7f70f34e5bed41d2a3bdad23b993735ea6
102+
--sha256: sha256-m1p+GGICoaU8x7XvEAFgtYHUDTKqFNSOMp7nfqN7s7k=
87103
subdir:
88104
cardano-cli
105+
106+
-- mempack support
107+
source-repository-package
108+
type: git
109+
location: https://github.com/IntersectMBO/cardano-base.git
110+
tag: fb9b71f3bc33f8de673c6427736f09bf7972e81f
111+
subdir:
112+
cardano-crypto-class
113+
--sha256: sha256-ExQ497FDYlmQyZaXOTddU+KraAUHnTAqPiyt055v0+M=
114+
115+
-- mempack support
116+
source-repository-package
117+
type: git
118+
location: https://github.com/IntersectMBO/cardano-ledger
119+
tag: c50d89688d9f30ea2dbd01afb19dbcaaf03e3da7
120+
--sha256: sha256-3OVXLYCKSN4HPd3nsObK2mG8mB28AX46vuMqs+Jn3kw=
121+
subdir:
122+
eras/allegra/impl
123+
eras/alonzo/impl
124+
eras/alonzo/test-suite
125+
eras/babbage/impl
126+
eras/babbage/test-suite
127+
eras/conway/impl
128+
eras/conway/test-suite
129+
eras/mary/impl
130+
eras/shelley/impl
131+
eras/shelley/test-suite
132+
eras/shelley-ma/test-suite
133+
libs/cardano-ledger-api
134+
libs/cardano-ledger-core
135+
libs/cardano-ledger-binary
136+
libs/cardano-protocol-tpraos
137+
libs/non-integral
138+
libs/small-steps
139+
libs/cardano-data
140+
libs/set-algebra
141+
libs/vector-map
142+
eras/byron/chain/executable-spec
143+
eras/byron/ledger/executable-spec
144+
eras/byron/ledger/impl
145+
eras/byron/ledger/impl/test
146+
eras/byron/crypto
147+
eras/byron/crypto/test

cardano-node/app/cardano-node.hs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ main = do
3535
case cmd of
3636
RunCmd args -> do
3737
warnIfSet args pncMaybeMempoolCapacityOverride "mempool-capacity-override" "MempoolCapacityBytesOverride"
38-
warnIfSet args pncNumOfDiskSnapshots "num-of-disk-snapshots" "NumOfDiskSnapshots"
39-
warnIfSet args pncSnapshotInterval "snapshot-interval" "SnapshotInterval"
4038
runNode args
4139
TraceDocumentation tdc -> runTraceDocumentationCmd tdc
4240
VersionCmd -> runVersionCommand
@@ -45,15 +43,15 @@ main = do
4543
p = Opt.prefs Opt.showHelpOnEmpty
4644

4745
warnIfSet :: PartialNodeConfiguration -> (PartialNodeConfiguration -> Last a) -> String -> String -> IO ()
48-
warnIfSet args f name key =
49-
maybe
50-
(pure ())
51-
(\_ -> hPutStrLn stderr $ "WARNING: Option --" ++ name ++ " was set via CLI flags.\
46+
warnIfSet args f name key =
47+
maybe
48+
(pure ())
49+
(\_ -> hPutStrLn stderr $ "WARNING: Option --" ++ name ++ " was set via CLI flags.\
5250
\ This CLI flag will be removed in upcoming node releases.\
53-
\ Please, set this configuration option in the configuration file instead with key " ++ key ++ ".")
51+
\ Please, set this configuration option in the configuration file instead with key " ++ key ++ ".")
5452
$ getLast
5553
$ f args
56-
54+
5755
opts :: Opt.ParserInfo Command
5856
opts =
5957
Opt.info (fmap RunCmd nodeCLIParser

cardano-node/cardano-node.cabal

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ library
7070
exposed-modules: Cardano.Node.Configuration.Logging
7171
Cardano.Node.Configuration.NodeAddress
7272
Cardano.Node.Configuration.POM
73+
Cardano.Node.Configuration.LedgerDB
7374
Cardano.Node.Configuration.Socket
7475
Cardano.Node.Configuration.Topology
7576
Cardano.Node.Configuration.TopologyP2P
@@ -206,6 +207,9 @@ library
206207
, stm <2.5.2 || >=2.5.3
207208
, strict-sop-core
208209
, strict-stm
210+
, sop-core
211+
, sop-extras
212+
, text >= 2.0
209213
, time
210214
, trace-dispatcher ^>= 2.7.0
211215
, trace-forward ^>= 2.2.8
@@ -269,7 +273,6 @@ test-suite cardano-node-test
269273
, ouroboros-network-api
270274
, strict-sop-core
271275
, text
272-
, time
273276
, transformers
274277
, vector
275278
, yaml
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
{-# LANGUAGE DataKinds #-}
2+
{-# LANGUAGE DerivingStrategies #-}
3+
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
4+
5+
{-# OPTIONS_GHC -Wno-orphans #-}
6+
7+
module Cardano.Node.Configuration.LedgerDB (
8+
LedgerDbConfiguration (..)
9+
, LedgerDbSelectorFlag(..)
10+
, Gigabytes
11+
, selectorToArgs
12+
) where
13+
14+
import Ouroboros.Consensus.Storage.LedgerDB.Args
15+
import Ouroboros.Consensus.Storage.LedgerDB.Snapshots
16+
import qualified Ouroboros.Consensus.Storage.LedgerDB.V1.Args as V1
17+
import Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.Impl.LMDB (LMDBLimits (..))
18+
import qualified Ouroboros.Consensus.Storage.LedgerDB.V2.Args as V2
19+
import Ouroboros.Consensus.Util.Args
20+
21+
import qualified Data.Aeson.Types as Aeson (FromJSON)
22+
import Data.Maybe (fromMaybe)
23+
import Data.SOP.Dict
24+
25+
-- | Choose the LedgerDB Backend
26+
--
27+
-- As of UTxO-HD, the LedgerDB now uses either an in-memory backend or LMDB to
28+
-- keep track of differences in the UTxO set.
29+
--
30+
-- - 'V2InMemory': uses more memory than the minimum requirements but is somewhat
31+
-- faster.
32+
--
33+
-- - 'V1LMDB': uses less memory but is somewhat slower.
34+
--
35+
-- - 'V1InMemory': Not intended for production. It is an in-memory reproduction
36+
-- of the LMDB implementation.
37+
data LedgerDbSelectorFlag =
38+
V1LMDB
39+
V1.FlushFrequency
40+
-- ^ The frequency at which changes are flushed to the disk.
41+
(Maybe FilePath)
42+
-- ^ Path for the live tables.
43+
(Maybe Gigabytes)
44+
-- ^ A map size can be specified, this is the maximum disk space the LMDB
45+
-- database can fill. If not provided, the default of 16GB will be used.
46+
| V1InMemory V1.FlushFrequency
47+
| V2InMemory
48+
deriving (Eq, Show)
49+
50+
data LedgerDbConfiguration =
51+
LedgerDbConfiguration
52+
NumOfDiskSnapshots
53+
SnapshotInterval
54+
QueryBatchSize
55+
LedgerDbSelectorFlag
56+
(Flag "DoDiskSnapshotChecksum")
57+
deriving (Eq, Show)
58+
59+
-- | A number of gigabytes.
60+
newtype Gigabytes = Gigabytes Int
61+
deriving stock (Eq, Show)
62+
deriving newtype (Read, Aeson.FromJSON)
63+
64+
-- | Convert a number of Gigabytes to the equivalent number of bytes.
65+
toBytes :: Gigabytes -> Int
66+
toBytes (Gigabytes x) = x * 1024 * 1024 * 1024
67+
68+
-- | Recommended settings for the LMDB backing store.
69+
--
70+
-- === @'lmdbMapSize'@
71+
-- The default @'LMDBLimits'@ uses an @'lmdbMapSize'@ of @1024 * 1024 * 1024 * 16@
72+
-- bytes, or 16 Gigabytes. @'lmdbMapSize'@ sets the size of the memory map
73+
-- that is used internally by the LMDB backing store, and is also the
74+
-- maximum size of the on-disk database. 16 GB should be sufficient for the
75+
-- medium term, i.e., it is sufficient until a more performant alternative to
76+
-- the LMDB backing store is implemented, which will probably replace the LMDB
77+
-- backing store altogether.
78+
--
79+
-- Note(jdral): It is recommended not to set the @'lmdbMapSize'@ to a value
80+
-- that is much smaller than 16 GB through manual configuration: the node will
81+
-- die with a fatal error as soon as the database size exceeds the
82+
-- @'lmdbMapSize'@. If this fatal error were to occur, we would expect that
83+
-- the node can continue normal operation if it is restarted with a higher
84+
-- @'lmdbMapSize'@ configured. Nonetheless, this situation should be avoided.
85+
--
86+
-- === @'lmdbMaxDatabases'@
87+
-- The @'lmdbMaxDatabases'@ is set to 10, which means that the LMDB backing
88+
-- store will allow up @<= 10@ internal databases. We say /internal/
89+
-- databases, since they are not exposed outside the backing store interface,
90+
-- such that from the outside view there is just one /logical/ database.
91+
-- Two of these internal databases are reserved for normal operation of the
92+
-- backing store, while the remaining databases will be used to store ledger
93+
-- tables. At the moment, there is at most one ledger table that will be
94+
-- stored in an internal database: the UTxO. Nonetheless, we set
95+
-- @'lmdbMaxDatabases'@ to @10@ in order to future-proof these limits.
96+
--
97+
-- === @'lmdbMaxReaders'@
98+
-- The @'lmdbMaxReaders'@ limit sets the maximum number of threads that can
99+
-- read from the LMDB database. Currently, there should only be a single reader
100+
-- active. Again, we set @'lmdbMaxReaders'@ to @16@ in order to future-proof
101+
-- these limits.
102+
--
103+
-- === References
104+
-- For more information about LMDB limits, one should inspect:
105+
-- * The @lmdb-simple@ and @haskell-lmdb@ forked repositories.
106+
-- * The official LMDB API documentation at
107+
-- <http://www.lmdb.tech/doc/group__mdb.html>.
108+
defaultLMDBLimits :: LMDBLimits
109+
defaultLMDBLimits = LMDBLimits {
110+
lmdbMapSize = 16 * 1024 * 1024 * 1024
111+
, lmdbMaxDatabases = 10
112+
, lmdbMaxReaders = 16
113+
}
114+
115+
defaultLMDBPath :: FilePath
116+
defaultLMDBPath = "mainnet/db/lmdb"
117+
118+
selectorToArgs :: LedgerDbSelectorFlag -> Complete LedgerDbFlavorArgs IO
119+
selectorToArgs (V1InMemory a) = LedgerDbFlavorArgsV1 $ V1.V1Args a V1.InMemoryBackingStoreArgs
120+
selectorToArgs V2InMemory = LedgerDbFlavorArgsV2 $ V2.V2Args V2.InMemoryHandleArgs
121+
selectorToArgs (V1LMDB a fp l) =
122+
LedgerDbFlavorArgsV1
123+
$ V1.V1Args a
124+
$ V1.LMDBBackingStoreArgs
125+
(fromMaybe defaultLMDBPath fp)
126+
(maybe id (\ll lim -> lim { lmdbMapSize = toBytes ll }) l defaultLMDBLimits)
127+
Dict

0 commit comments

Comments
 (0)