Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: UTXO-HD for node 8.9.1 #5726

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2260d52
UTXO-HD ONE COMMIT
jasagredo Feb 29, 2024
edb5012
WIP args
jasagredo Mar 4, 2024
d2bc4d8
Update packages
jasagredo Mar 25, 2024
4d72e00
Make tests build
jasagredo Mar 25, 2024
29c7c40
Update cabal.project refs
jasagredo Mar 26, 2024
7709ac8
Update cabal.project refs
jasagredo Apr 4, 2024
6b2f2d2
Add lmdb to CI
jasagredo Apr 4, 2024
9e2ba4b
Update cabal.project refs
jasagredo Apr 4, 2024
1595dc8
Replace SnapshotInterval with SnapshotPolicyArgs
Mar 27, 2024
734c5b3
Update NewEpochState with tables
Apr 5, 2024
123b5b6
Update consensus refs and CHaP
jasagredo Apr 5, 2024
18691b8
Fix missing NumOfDiskSnapshots field in POM test
Apr 5, 2024
513fa9e
Invalidate cabal cache
jasagredo Apr 5, 2024
82305f7
Update cabal.project refs and CHaP
jasagredo Apr 5, 2024
0b9a3d6
Update cabal.project refs
jasagredo Apr 5, 2024
fe5a0db
Bump refs, stylish, hlint
jasagredo Apr 8, 2024
772d003
WIP
jasagredo Apr 9, 2024
d73bf1d
Implement Forker traces
jasagredo Apr 9, 2024
7c2cea1
Update consensus ref
jasagredo Apr 9, 2024
584a3a5
Add instances for BackingStoreTrace
Apr 9, 2024
777aa4a
LogFormatting and MetaTrace instances for V2.FlavorImplSpecificTrace
fraser-iohk Apr 10, 2024
f3c7b1b
Merge pull request #5773 from IntersectMBO/fraser-iohk/utxo-hd-tracing
jasagredo Apr 10, 2024
c9be96d
Do not break ellision by forkers
jasagredo Apr 10, 2024
c02f23d
Fix namespaces
jasagredo Apr 10, 2024
c18f095
Merge pull request #5768 from IntersectMBO/utxo-tracers
jasagredo Apr 11, 2024
d934a4e
Update cabal.project refs
jasagredo Apr 15, 2024
de208db
update cabal.project
jasagredo May 23, 2024
e289e2b
Update refs
jasagredo May 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

env:
# Modify this value to "invalidate" the cabal cache.
CABAL_CACHE_VERSION: "2024-02-29"
CABAL_CACHE_VERSION: "2024-04-05-2"

concurrency:
group: >
Expand Down Expand Up @@ -75,6 +75,19 @@ jobs:
with:
use-sodium-vrf: true # default is true

- name: Linux install lmdb
if: matrix.os == 'ubuntu-latest'
run: sudo apt install liblmdb-dev

- name: Mac install lmdb
if: matrix.os == 'macos-latest'
run: brew install lmdb

- name: Windows install lmdb
if: matrix.os == 'windows-latest'
shell: 'C:/msys64/usr/bin/bash.exe -e {0}'
run: /usr/bin/pacman --noconfirm -S mingw-w64-x86_64-lmdb

- uses: actions/checkout@v3

- name: Cabal update
Expand Down
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
/cabal.project.old
configuration/defaults/simpleview/genesis/
configuration/defaults/liveview/genesis/
dist-newstyle/
dist-profiled/
dist-*
dist/
*~
\#*
Expand All @@ -19,12 +18,13 @@ dist/
result*
/launch-*
stack.yaml.lock
.ghcid

/.cache
/db
/db-[0-9]
/logs
/mainnet
/mainnet*
/profile
/launch_*
/state-*
Expand Down
25 changes: 23 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ repository cardano-haskell-packages
-- See CONTRIBUTING for information about these, including some Nix commands
-- you need to run if you change them
index-state:
, hackage.haskell.org 2024-03-20T14:55:30Z
, cardano-haskell-packages 2024-03-20T14:22:58Z
, hackage.haskell.org 2024-03-25T10:39:21Z
, cardano-haskell-packages 2024-05-24T09:29:56Z

packages:
cardano-git-rev
Expand Down Expand Up @@ -60,3 +60,24 @@ package plutus-scripts-bench
-- temporary! Please read the section in CONTRIBUTING about updating dependencies.

-- `smtp-mail` should depend on `crypton-connection` rather than `connection`!

source-repository-package
type: git
location: https://github.com/IntersectMBO/ouroboros-consensus
tag: 858fbd77bca6c423a44feef41e31adaf0400e267
--sha256: 0bxxvw96nsg22pmxxlf1fzr7g09xi6b60frvjngrwidlsv31nf2q
subdir:
ouroboros-consensus
ouroboros-consensus-cardano
ouroboros-consensus-diffusion
ouroboros-consensus-protocol
sop-extras
strict-sop-core

source-repository-package
type: git
location: https://github.com/IntersectMBO/cardano-api
tag: 239a713e8fdfca85ae4516e94d6cb8971ec6ca0f
--sha256: 1i4sc446w9mggpxf78zkglk34mjafwhyrmp3fvb7mkkk9347ziwd
subdir:
cardano-api
4 changes: 4 additions & 0 deletions cardano-node/cardano-node.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ library
exposed-modules: Cardano.Node.Configuration.Logging
Cardano.Node.Configuration.NodeAddress
Cardano.Node.Configuration.POM
Cardano.Node.Configuration.LedgerDB
Cardano.Node.Configuration.Socket
Cardano.Node.Configuration.Topology
Cardano.Node.Configuration.TopologyP2P
Expand Down Expand Up @@ -201,6 +202,9 @@ library
, stm
, strict-sop-core
, strict-stm
, sop-core
, sop-extras
, text >= 2.0
, time
, trace-dispatcher ^>= 2.5
, trace-forward ^>= 2.2
Expand Down
103 changes: 103 additions & 0 deletions cardano-node/src/Cardano/Node/Configuration/LedgerDB.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE GeneralisedNewtypeDeriving #-}

{-# OPTIONS_GHC -Wno-orphans #-}

module Cardano.Node.Configuration.LedgerDB (
LedgerDbSelectorFlag(..)
, Gigabytes
, toBytes
, defaultLMDBLimits
, selectorToArgs
) where

import Ouroboros.Consensus.Storage.LedgerDB.Impl.Args
import qualified Ouroboros.Consensus.Storage.LedgerDB.V1.Args as V1
import Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.Impl.LMDB (LMDBLimits (..))
import qualified Ouroboros.Consensus.Storage.LedgerDB.V2.Args as V2
import Ouroboros.Consensus.Util.Args

import qualified Data.Aeson.Types as Aeson (FromJSON)
import Data.SOP.Dict

-- | Choose the LedgerDB Backend
--
-- As of UTxO-HD, the LedgerDB now uses either an in-memory backend or LMDB to
-- keep track of differences in the UTxO set.
--
-- - 'InMemory': uses more memory than the minimum requirements but is somewhat
-- faster.
-- - 'LMDB': uses less memory but is somewhat slower.
--
-- See 'Ouroboros.Consnesus.Storage.LedgerDB.OnDisk.BackingStoreSelector'.
data LedgerDbSelectorFlag =
V1LMDB (Maybe Gigabytes) -- ^ A map size can be specified, this is the maximum
-- disk space the LMDB database can fill. If not
-- provided, the default of 16GB will be used.
| V1InMemory
| V2InMemory
deriving (Eq, Show)

-- | A number of gigabytes.
newtype Gigabytes = Gigabytes Int
deriving stock (Eq, Show)
deriving newtype (Read, Aeson.FromJSON)

-- | Convert a number of Gigabytes to the equivalent number of bytes.
toBytes :: Gigabytes -> Int
toBytes (Gigabytes x) = x * 1024 * 1024 * 1024

-- | Recommended settings for the LMDB backing store.
--
-- === @'lmdbMapSize'@
-- The default @'LMDBLimits'@ uses an @'lmdbMapSize'@ of @1024 * 1024 * 1024 * 16@
-- bytes, or 16 Gigabytes. @'lmdbMapSize'@ sets the size of the memory map
-- that is used internally by the LMDB backing store, and is also the
-- maximum size of the on-disk database. 16 GB should be sufficient for the
-- medium term, i.e., it is sufficient until a more performant alternative to
-- the LMDB backing store is implemented, which will probably replace the LMDB
-- backing store altogether.
--
-- Note(jdral): It is recommended not to set the @'lmdbMapSize'@ to a value
-- that is much smaller than 16 GB through manual configuration: the node will
-- die with a fatal error as soon as the database size exceeds the
-- @'lmdbMapSize'@. If this fatal error were to occur, we would expect that
-- the node can continue normal operation if it is restarted with a higher
-- @'lmdbMapSize'@ configured. Nonetheless, this situation should be avoided.
--
-- === @'lmdbMaxDatabases'@
-- The @'lmdbMaxDatabases'@ is set to 10, which means that the LMDB backing
-- store will allow up @<= 10@ internal databases. We say /internal/
-- databases, since they are not exposed outside the backing store interface,
-- such that from the outside view there is just one /logical/ database.
-- Two of these internal databases are reserved for normal operation of the
-- backing store, while the remaining databases will be used to store ledger
-- tables. At the moment, there is at most one ledger table that will be
-- stored in an internal database: the UTxO. Nonetheless, we set
-- @'lmdbMaxDatabases'@ to @10@ in order to future-proof these limits.
--
-- === @'lmdbMaxReaders'@
-- The @'lmdbMaxReaders'@ limit sets the maximum number of threads that can
-- read from the LMDB database. Currently, there should only be a single reader
-- active. Again, we set @'lmdbMaxReaders'@ to @16@ in order to future-proof
-- these limits.
--
-- === References
-- For more information about LMDB limits, one should inspect:
-- * The @lmdb-simple@ and @haskell-lmdb@ forked repositories.
-- * The official LMDB API documentation at
-- <http://www.lmdb.tech/doc/group__mdb.html>.
defaultLMDBLimits :: LMDBLimits
defaultLMDBLimits = LMDBLimits {
lmdbMapSize = 16 * 1024 * 1024 * 1024
, lmdbMaxDatabases = 10
, lmdbMaxReaders = 16
}

selectorToArgs :: LedgerDbSelectorFlag -> V1.FlushFrequency -> V1.QueryBatchSize -> Complete LedgerDbFlavorArgs IO
selectorToArgs V1InMemory a b = LedgerDbFlavorArgsV1 $ V1.V1Args a b V1.InMemoryBackingStoreArgs
selectorToArgs V2InMemory _ _ = LedgerDbFlavorArgsV2 $ V2.V2Args V2.InMemoryHandleArgs
selectorToArgs (V1LMDB l) a b=
LedgerDbFlavorArgsV1
$ V1.V1Args a b
$ V1.LMDBBackingStoreArgs (maybe id (\ll lim -> lim { lmdbMapSize = toBytes ll }) l defaultLMDBLimits) Dict
Loading
Loading