Skip to content

Commit 007d739

Browse files
committed
UTXO-HD
1 parent e078e3d commit 007d739

File tree

46 files changed

+1361
-443
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1361
-443
lines changed

.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-*

bench/plutus-scripts-bench/plutus-scripts-bench.cabal

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ library
8282
-- IOG dependencies
8383
--------------------------
8484
build-depends:
85-
, cardano-api ^>=10.13.1
86-
, plutus-ledger-api ^>=1.43
87-
, plutus-tx ^>=1.43
88-
, plutus-tx-plugin ^>=1.43
85+
, cardano-api ^>=10.14
86+
, plutus-ledger-api ^>=1.45
87+
, plutus-tx ^>=1.45
88+
, plutus-tx-plugin ^>=1.45
8989

9090
------------------------
9191
-- Non-IOG dependencies

bench/plutus-scripts-bench/src/Cardano/Benchmarking/PlutusScripts/CustomCall.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import Cardano.Api.Shelley (PlutusScript (..), PlutusScriptVersion (..
2121
import qualified Data.ByteString.Short as SBS
2222
import qualified PlutusLedgerApi.V2 as PlutusV2
2323
import qualified PlutusTx
24+
import PlutusTx.Foldable (sum)
25+
import PlutusTx.List (length, all)
2426
import PlutusTx.Prelude as Plutus hiding (Semigroup (..), (.), (<$>))
2527

2628
import Cardano.Benchmarking.ScriptAPI

bench/tx-generator/tx-generator.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ library
113113
, attoparsec-aeson
114114
, base16-bytestring
115115
, bytestring
116-
, cardano-api ^>= 10.13.1
116+
, cardano-api ^>= 10.14
117117
, cardano-binary
118-
, cardano-cli ^>= 10.7
118+
, cardano-cli ^>= 10.8
119119
, cardano-crypto-class
120120
, cardano-crypto-wrapper
121121
, cardano-data

cabal.project

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ 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 2025-03-18T07:42:38Z
17-
, cardano-haskell-packages 2025-04-08T17:22:48Z
16+
, hackage.haskell.org 2025-04-16T18:30:40Z
17+
, cardano-haskell-packages 2025-04-22T10:01:33Z
1818

1919
packages:
2020
cardano-node
@@ -91,10 +91,3 @@ if impl (ghc >= 9.12)
9191
, servant:base
9292
, servant-server:base
9393

94-
-- https://github.com/IntersectMBO/ouroboros-consensus/blob/main/cabal.project#L70-L74
95-
, ouroboros-network-protocols:base
96-
, ouroboros-network-framework:base
97-
, ouroboros-network-api:base
98-
, network-mux:base
99-
, ouroboros-network:base
100-
, cardano-ping:base

cardano-node-chairman/cardano-node-chairman.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,5 @@ test-suite chairman-tests
9090
ghc-options: -threaded -rtsopts "-with-rtsopts=-N -T"
9191

9292
build-tool-depends: cardano-node:cardano-node
93-
, cardano-cli:cardano-cli ^>= 10.7
93+
, cardano-cli:cardano-cli ^>= 10.8
9494
, cardano-node-chairman:cardano-node-chairman

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: 8 additions & 5 deletions
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
@@ -146,7 +147,7 @@ library
146147
, async
147148
, base16-bytestring
148149
, bytestring
149-
, cardano-api ^>= 10.13.1
150+
, cardano-api ^>= 10.14
150151
, cardano-crypto-class
151152
, cardano-crypto-wrapper
152153
, cardano-git-rev ^>=0.2.2
@@ -189,9 +190,9 @@ library
189190
, network-mux >= 0.5
190191
, nothunks
191192
, optparse-applicative-fork >= 0.18.1
192-
, ouroboros-consensus ^>= 0.24
193-
, ouroboros-consensus-cardano ^>= 0.23
194-
, ouroboros-consensus-diffusion ^>= 0.21
193+
, ouroboros-consensus ^>= 0.26
194+
, ouroboros-consensus-cardano ^>= 0.25
195+
, ouroboros-consensus-diffusion ^>= 0.22
195196
, ouroboros-consensus-protocol
196197
, ouroboros-network-api ^>= 0.13
197198
, ouroboros-network ^>= 0.20
@@ -210,6 +211,9 @@ library
210211
, stm <2.5.2 || >=2.5.3
211212
, strict-sop-core
212213
, strict-stm
214+
, sop-core
215+
, sop-extras
216+
, text >= 2.0
213217
, time
214218
, trace-dispatcher ^>= 2.9
215219
, trace-forward ^>= 2.2.11
@@ -273,7 +277,6 @@ test-suite cardano-node-test
273277
, ouroboros-network-api
274278
, strict-sop-core
275279
, text
276-
, time
277280
, transformers
278281
, vector
279282
, yaml
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
{-# LANGUAGE DataKinds #-}
2+
{-# LANGUAGE DerivingStrategies #-}
3+
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
4+
5+
{-# OPTIONS_GHC -Wno-orphans #-}
6+
7+
module Cardano.Node.Configuration.LedgerDB (
8+
DeprecatedOptions (..)
9+
, LedgerDbConfiguration (..)
10+
, LedgerDbSelectorFlag(..)
11+
, Gigabytes
12+
, noDeprecatedOptions
13+
, selectorToArgs
14+
) where
15+
16+
import Ouroboros.Consensus.Storage.LedgerDB.Args
17+
import Ouroboros.Consensus.Storage.LedgerDB.Snapshots
18+
import qualified Ouroboros.Consensus.Storage.LedgerDB.V1.Args as V1
19+
import Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.Impl.LMDB (LMDBLimits (..))
20+
import qualified Ouroboros.Consensus.Storage.LedgerDB.V2.Args as V2
21+
import Ouroboros.Consensus.Util.Args
22+
23+
import qualified Data.Aeson.Types as Aeson (FromJSON)
24+
import Data.Maybe (fromMaybe)
25+
import Data.SOP.Dict
26+
27+
-- | Choose the LedgerDB Backend
28+
--
29+
-- As of UTxO-HD, the LedgerDB now uses either an in-memory backend or LMDB to
30+
-- keep track of differences in the UTxO set.
31+
--
32+
-- - 'V2InMemory': uses more memory than the minimum requirements but is somewhat
33+
-- faster.
34+
--
35+
-- - 'V1LMDB': uses less memory but is somewhat slower.
36+
--
37+
-- - 'V1InMemory': Not intended for production. It is an in-memory reproduction
38+
-- of the LMDB implementation.
39+
data LedgerDbSelectorFlag =
40+
V1LMDB
41+
V1.FlushFrequency
42+
-- ^ The frequency at which changes are flushed to the disk.
43+
(Maybe FilePath)
44+
-- ^ Path for the live tables.
45+
(Maybe Gigabytes)
46+
-- ^ A map size can be specified, this is the maximum disk space the LMDB
47+
-- database can fill. If not provided, the default of 16GB will be used.
48+
| V1InMemory V1.FlushFrequency
49+
| V2InMemory
50+
deriving (Eq, Show)
51+
52+
-- | Some options that existed in the TopLevel were now moved to a
53+
-- subsection. We use this field to propagate the results from parsing those
54+
-- into the monadic part of the node so that we can emit warnings.
55+
newtype DeprecatedOptions = DeprecatedOptions [String]
56+
deriving (Eq, Show)
57+
58+
noDeprecatedOptions :: DeprecatedOptions
59+
noDeprecatedOptions = DeprecatedOptions []
60+
61+
data LedgerDbConfiguration =
62+
LedgerDbConfiguration
63+
NumOfDiskSnapshots
64+
SnapshotInterval
65+
QueryBatchSize
66+
LedgerDbSelectorFlag
67+
DeprecatedOptions
68+
deriving (Eq, Show)
69+
70+
-- | A number of gigabytes.
71+
newtype Gigabytes = Gigabytes Int
72+
deriving stock (Eq, Show)
73+
deriving newtype (Read, Aeson.FromJSON)
74+
75+
-- | Convert a number of Gigabytes to the equivalent number of bytes.
76+
toBytes :: Gigabytes -> Int
77+
toBytes (Gigabytes x) = x * 1024 * 1024 * 1024
78+
79+
-- | Recommended settings for the LMDB backing store.
80+
--
81+
-- === @'lmdbMapSize'@
82+
-- The default @'LMDBLimits'@ uses an @'lmdbMapSize'@ of @1024 * 1024 * 1024 * 16@
83+
-- bytes, or 16 Gigabytes. @'lmdbMapSize'@ sets the size of the memory map
84+
-- that is used internally by the LMDB backing store, and is also the
85+
-- maximum size of the on-disk database. 16 GB should be sufficient for the
86+
-- medium term, i.e., it is sufficient until a more performant alternative to
87+
-- the LMDB backing store is implemented, which will probably replace the LMDB
88+
-- backing store altogether.
89+
--
90+
-- Note(jdral): It is recommended not to set the @'lmdbMapSize'@ to a value
91+
-- that is much smaller than 16 GB through manual configuration: the node will
92+
-- die with a fatal error as soon as the database size exceeds the
93+
-- @'lmdbMapSize'@. If this fatal error were to occur, we would expect that
94+
-- the node can continue normal operation if it is restarted with a higher
95+
-- @'lmdbMapSize'@ configured. Nonetheless, this situation should be avoided.
96+
--
97+
-- === @'lmdbMaxDatabases'@
98+
-- The @'lmdbMaxDatabases'@ is set to 10, which means that the LMDB backing
99+
-- store will allow up @<= 10@ internal databases. We say /internal/
100+
-- databases, since they are not exposed outside the backing store interface,
101+
-- such that from the outside view there is just one /logical/ database.
102+
-- Two of these internal databases are reserved for normal operation of the
103+
-- backing store, while the remaining databases will be used to store ledger
104+
-- tables. At the moment, there is at most one ledger table that will be
105+
-- stored in an internal database: the UTxO. Nonetheless, we set
106+
-- @'lmdbMaxDatabases'@ to @10@ in order to future-proof these limits.
107+
--
108+
-- === @'lmdbMaxReaders'@
109+
-- The @'lmdbMaxReaders'@ limit sets the maximum number of threads that can
110+
-- read from the LMDB database. Currently, there should only be a single reader
111+
-- active. Again, we set @'lmdbMaxReaders'@ to @16@ in order to future-proof
112+
-- these limits.
113+
--
114+
-- === References
115+
-- For more information about LMDB limits, one should inspect:
116+
-- * The @lmdb-simple@ and @haskell-lmdb@ forked repositories.
117+
-- * The official LMDB API documentation at
118+
-- <http://www.lmdb.tech/doc/group__mdb.html>.
119+
defaultLMDBLimits :: LMDBLimits
120+
defaultLMDBLimits = LMDBLimits {
121+
lmdbMapSize = 16 * 1024 * 1024 * 1024
122+
, lmdbMaxDatabases = 10
123+
, lmdbMaxReaders = 16
124+
}
125+
126+
defaultLMDBPath :: FilePath
127+
defaultLMDBPath = "mainnet/db/lmdb"
128+
129+
selectorToArgs :: LedgerDbSelectorFlag -> Complete LedgerDbFlavorArgs IO
130+
selectorToArgs (V1InMemory ff) = LedgerDbFlavorArgsV1 $ V1.V1Args ff V1.InMemoryBackingStoreArgs
131+
selectorToArgs V2InMemory = LedgerDbFlavorArgsV2 $ V2.V2Args V2.InMemoryHandleArgs
132+
selectorToArgs (V1LMDB ff fp l) =
133+
LedgerDbFlavorArgsV1
134+
$ V1.V1Args ff
135+
$ V1.LMDBBackingStoreArgs
136+
(fromMaybe defaultLMDBPath fp)
137+
(maybe id (\ll lim -> lim { lmdbMapSize = toBytes ll }) l defaultLMDBLimits)
138+
Dict

0 commit comments

Comments
 (0)