Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion bench/plutus-scripts-bench/plutus-scripts-bench.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ library
-- IOG dependencies
--------------------------
build-depends:
, cardano-api ^>=10.19
, cardano-api ^>=10.20
, plutus-ledger-api ^>=1.53
, plutus-tx ^>=1.53
, plutus-tx-plugin ^>=1.53
Expand Down
2 changes: 1 addition & 1 deletion bench/tx-generator/tx-generator.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ library
, attoparsec-aeson
, base16-bytestring
, bytestring
, cardano-api ^>= 10.19
, cardano-api ^>= 10.20
, cardano-binary
, cardano-cli ^>= 10.13
, cardano-crypto-class
Expand Down
74 changes: 65 additions & 9 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ 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 2025-10-17T00:26:22Z
, hackage.haskell.org 2025-12-03T15:53:31Z
, cardano-haskell-packages 2025-11-20T19:55:27Z

packages:
Expand Down Expand Up @@ -61,14 +61,70 @@ package plutus-scripts-bench
allow-newer:
, katip:Win32

if impl (ghc >= 9.12)
allow-newer:
-- https://github.com/kapralVV/Unique/issues/11
, Unique:hashable

-- https://github.com/Gabriella439/Haskell-Pipes-Safe-Library/pull/70
, pipes-safe:base

-- IMPORTANT
-- Do NOT add more source-repository-package stanzas here unless they are strictly
-- temporary! Please read the section in CONTRIBUTING about updating dependencies.
source-repository-package
type: git
location: https://github.com/intersectmbo/cardano-cli.git
tag: 9bed9ca66fb4d0d7854e748c681d842bac202051
--sha256: sha256-7q/g7RHjO1sSW8RDiq47TpQccVOHOciDohgavH/g9t8=
subdir: cardano-cli

source-repository-package
type: git
location: https://github.com/IntersectMBO/cardano-api
tag: 3d33855a5af6c6f2bb37b0c417f1ceb474ae079f
--sha256: sha256-zsEu8ZxF5/fLgokv/4kkII3j8/JbCvrnsHDueQyI6xI=
subdir:
cardano-api

source-repository-package
type: git
location: https://github.com/IntersectMBO/ouroboros-consensus
tag: baf4ebbd924433543f8c5142b370b1061ac2e7bb
--sha256: sha256-dCNFxrLF7MPqNRc9aIwl2AZpjHqw9dGerTudo7GQzao=
subdir:
ouroboros-consensus
ouroboros-consensus-cardano
ouroboros-consensus-diffusion

source-repository-package
type: git
location: https://github.com/IntersectMBO/cardano-ledger
tag: fb09078fa55015c881303a2ddb609c024cec258f
--sha256: sha256-9Y9CRiyMn0AWD+C4aNVMaJgrj3FDAYfCX4VrLvtoMaI=
subdir:
eras/allegra/impl
eras/alonzo/impl
eras/alonzo/test-suite
eras/babbage/impl
eras/conway/impl
eras/dijkstra/impl
eras/mary/impl
eras/shelley/impl
eras/shelley/test-suite
eras/shelley-ma/test-suite
libs/cardano-ledger-api
libs/cardano-ledger-core
libs/cardano-ledger-binary
libs/cardano-protocol-tpraos
libs/non-integral
libs/small-steps
libs/cardano-data
libs/set-algebra
libs/vector-map
eras/byron/chain/executable-spec
eras/byron/ledger/executable-spec
eras/byron/ledger/impl
eras/byron/crypto

-- Backported version of https://github.com/IntersectMBO/ouroboros-network/pull/5161
source-repository-package
type: git
location: https://github.com/IntersectMBO/ouroboros-network
tag: dfcb1f9c578ec8cd5114fea9696e7be6c9001323
--sha256: sha256-omXPdi/T/f3gq9rOH20zX+x3WvaxlB704g07RF/13Nk=
subdir:
ouroboros-network-api
ouroboros-network
2 changes: 1 addition & 1 deletion cardano-node-chairman/cardano-node-chairman.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ executable cardano-node-chairman
build-depends: cardano-api
, cardano-crypto-class
, cardano-git-rev ^>= 0.2.2
, cardano-ledger-core ^>= 1.18
, cardano-ledger-core ^>= 1.19
, cardano-node ^>= 10.6
, cardano-prelude
, containers
Expand Down
4 changes: 2 additions & 2 deletions cardano-node/cardano-node.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ library
, async
, base16-bytestring
, bytestring
, cardano-api ^>= 10.19
, cardano-api ^>= 10.20
, cardano-crypto-class ^>=2.2.3.2
, cardano-crypto-wrapper
, cardano-git-rev ^>=0.2.2
Expand Down Expand Up @@ -185,7 +185,7 @@ library
, network-mux >= 0.8
, nothunks
, optparse-applicative-fork >= 0.18.1
, ouroboros-consensus ^>= 0.28
, ouroboros-consensus:{ouroboros-consensus, ouroboros-consensus-lmdb, ouroboros-consensus-lsm} ^>= 0.28
, ouroboros-consensus-cardano ^>= 0.26
, ouroboros-consensus-diffusion ^>= 0.24
, ouroboros-consensus-protocol
Expand Down
76 changes: 43 additions & 33 deletions cardano-node/src/Cardano/Node/Configuration/LedgerDB.hs
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}

{-# OPTIONS_GHC -Wno-orphans #-}

module Cardano.Node.Configuration.LedgerDB (
DeprecatedOptions (..)
, LedgerDbConfiguration (..)
, LedgerDbSelectorFlag(..)
, Gigabytes
, noDeprecatedOptions
, selectorToArgs
) where
DeprecatedOptions (..),
LedgerDbConfiguration (..),
LedgerDbSelectorFlag (..),
Gigabytes,
noDeprecatedOptions,
selectorToArgs,
) where

import Ouroboros.Consensus.Ledger.SupportsProtocol
import Ouroboros.Consensus.Storage.LedgerDB.API
import Ouroboros.Consensus.Storage.LedgerDB.Args
import Ouroboros.Consensus.Storage.LedgerDB.Snapshots
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 Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.Impl.LMDB as LMDB
import qualified Ouroboros.Consensus.Storage.LedgerDB.V2.InMemory as InMemory
import qualified Ouroboros.Consensus.Storage.LedgerDB.V2.LSM as LSM

import qualified Data.Aeson.Types as Aeson (FromJSON)
import Data.Maybe (fromMaybe)
import Data.SOP.Dict
import Data.Proxy
import System.FilePath
import System.Random (StdGen)

-- | Choose the LedgerDB Backend
--
Expand All @@ -34,21 +41,25 @@ import Data.SOP.Dict
--
-- - 'V1LMDB': uses less memory but is somewhat slower.
--
-- - 'V1InMemory': Not intended for production. It is an in-memory reproduction
-- of the LMDB implementation.
-- - 'V2LSM': Uses the LSM backend.
data LedgerDbSelectorFlag =
V1LMDB
V1.FlushFrequency
-- ^ The frequency at which changes are flushed to the disk.
(Maybe FilePath)
-- ^ Path for the live tables.
-- ^ Path for the live tables. If not provided the default will be used
-- (@<fast-storage>/lmdb@).
(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.
(Maybe Int)
-- ^ An override to the max number of readers.
| V1InMemory V1.FlushFrequency
| V2InMemory
| V2LSM
(Maybe FilePath)
-- ^ Maybe a custom path to the LSM database. If not provided the default
-- will be used (@<fast-storage>/lsm@).

deriving (Eq, Show)

-- | Some options that existed in the TopLevel were now moved to a
Expand Down Expand Up @@ -118,24 +129,23 @@ toBytes (Gigabytes x) = x * 1024 * 1024 * 1024
-- * 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
defaultLMDBLimits :: LMDB.LMDBLimits
defaultLMDBLimits = LMDB.LMDBLimits {
LMDB.lmdbMapSize = 16 * 1024 * 1024 * 1024
, LMDB.lmdbMaxDatabases = 10
, LMDB.lmdbMaxReaders = 16
}

defaultLMDBPath :: FilePath
defaultLMDBPath = "mainnet/db/lmdb"
defaultLMDBPath :: FilePath -> FilePath
defaultLMDBPath = (</> "lmdb")

selectorToArgs :: LedgerDbSelectorFlag -> Complete LedgerDbFlavorArgs IO
selectorToArgs (V1InMemory ff) = LedgerDbFlavorArgsV1 $ V1.V1Args ff V1.InMemoryBackingStoreArgs
selectorToArgs V2InMemory = LedgerDbFlavorArgsV2 $ V2.V2Args V2.InMemoryHandleArgs
selectorToArgs (V1LMDB ff fp l mxReaders) =
LedgerDbFlavorArgsV1
$ V1.V1Args ff
$ V1.LMDBBackingStoreArgs
(fromMaybe defaultLMDBPath fp)
(maybe id (\overrideMaxReaders lim -> lim { lmdbMaxReaders = overrideMaxReaders }) mxReaders
$ maybe id (\ll lim -> lim { lmdbMapSize = toBytes ll }) l defaultLMDBLimits)
Dict
selectorToArgs :: forall blk. (LedgerSupportsProtocol blk, LedgerSupportsLedgerDB blk) => LedgerDbSelectorFlag -> FilePath -> StdGen -> (LedgerDbBackendArgs IO blk, StdGen)
selectorToArgs V2InMemory _ = InMemory.mkInMemoryArgs
selectorToArgs (V1LMDB ff fp l mxReaders) fastStoragePath =
LMDB.mkLMDBArgs
ff
(fromMaybe (defaultLMDBPath fastStoragePath) fp)
( maybe id (\overrideMaxReaders lim -> lim{LMDB.lmdbMaxReaders = overrideMaxReaders}) mxReaders $
maybe id (\ll lim -> lim{LMDB.lmdbMapSize = toBytes ll}) l defaultLMDBLimits
)
selectorToArgs (V2LSM fp) fastStoragePath = LSM.mkLSMArgs (Proxy @blk) (fromMaybe "lsm" fp) fastStoragePath
22 changes: 15 additions & 7 deletions cardano-node/src/Cardano/Node/Configuration/POM.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import Cardano.Tracing.Config
import Cardano.Tracing.OrphanInstances.Network ()
import Ouroboros.Consensus.Ledger.SupportsMempool
import Ouroboros.Consensus.Mempool (MempoolCapacityBytesOverride (..))
import Ouroboros.Consensus.Node (NodeDatabasePaths (..))
import Ouroboros.Consensus.Node (NodeDatabasePaths (..), nonImmutableDbPath)
import Ouroboros.Consensus.Node.Genesis (GenesisConfig, GenesisConfigFlags,
defaultGenesisConfigFlags, mkGenesisConfig)
import Ouroboros.Consensus.Storage.LedgerDB.Args (QueryBatchSize (..))
Expand Down Expand Up @@ -466,16 +466,16 @@ instance FromJSON PartialNodeConfiguration where
qsize <- (fmap RequestedQueryBatchSize <$> o .:? "QueryBatchSize") .!= DefaultQueryBatchSize
backend <- o .:? "Backend" .!= "V2InMemory"
selector <- case backend of
"V1InMemory" -> do
flush <- (fmap RequestedFlushFrequency <$> o .:? "FlushFrequency") .!= DefaultFlushFrequency
return $ V1InMemory flush
"V1LMDB" -> do
flush <- (fmap RequestedFlushFrequency <$> o .:? "FlushFrequency") .!= DefaultFlushFrequency
mapSize :: Maybe Gigabytes <- o .:? "MapSize"
lmdbPath :: Maybe FilePath <- o .:? "LiveTablesPath"
mxReaders :: Maybe Int <- o .:? "MaxReaders"
return $ V1LMDB flush lmdbPath mapSize mxReaders
"V2InMemory" -> return V2InMemory
"V2LSM" -> do
lsmPath :: Maybe FilePath <- o .:? "LSMDatabasePath"
pure $ V2LSM lsmPath
_ -> fail $ "Malformed LedgerDB Backend: " <> backend
pure $ Just $ LedgerDbConfiguration ldbSnapNum ldbSnapInterval qsize selector deprecatedOpts

Expand Down Expand Up @@ -759,9 +759,6 @@ makeNodeConfiguration pnc = do
ncConsensusMode <-
lastToEither "Missing ConsensusMode"
$ pncConsensusMode pnc
ncLedgerDbConfig <-
lastToEither "Missing LedgerDb config"
$ pncLedgerDbConfig pnc
ncProtocolIdleTimeout <-
lastToEither "Missing ProtocolIdleTimeout"
$ pncProtocolIdleTimeout pnc
Expand Down Expand Up @@ -798,6 +795,17 @@ makeNodeConfiguration pnc = do

ncResponderCoreAffinityPolicy <- lastToEither "Missing ResponderCoreAffinityPolicy" $ pncResponderCoreAffinityPolicy pnc

let
fixupConsensusDbPath (LedgerDbConfiguration ds si qbs (V1LMDB ff Nothing mg mi) dopt) =
LedgerDbConfiguration ds si qbs (V1LMDB ff (Just $ nonImmutableDbPath databaseFile </> "lmdb") mg mi) dopt
fixupConsensusDbPath (LedgerDbConfiguration ds si qbs (V2LSM Nothing) dopt) =
LedgerDbConfiguration ds si qbs (V2LSM (Just $ nonImmutableDbPath databaseFile </> "lsm")) dopt
fixupConsensusDbPath l = l

ncLedgerDbConfig <-
fixupConsensusDbPath
<$> lastToEither "Missing LedgerDb config" (pncLedgerDbConfig pnc)

let deadlineTargets =
PeerSelectionTargets {
targetNumberOfRootPeers = ncDeadlineTargetOfRootPeers,
Expand Down
5 changes: 2 additions & 3 deletions cardano-node/src/Cardano/Node/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ import Cardano.Tracing.Tracers
import qualified Ouroboros.Consensus.Config as Consensus
import Ouroboros.Consensus.Config.SupportsNode (ConfigSupportsNode (..))
import Ouroboros.Consensus.Node (SnapshotPolicyArgs (..),
NodeDatabasePaths (..), RunNodeArgs (..), StdRunNodeArgs (..))
NodeDatabasePaths (..), nonImmutableDbPath, RunNodeArgs (..), StdRunNodeArgs (..))
import Ouroboros.Consensus.Protocol.Praos.AgentClient (KESAgentClientTrace)
import Ouroboros.Consensus.Ledger.SupportsMempool (GenTxId)
import Ouroboros.Consensus.Node (RunNodeArgs (..),
Expand All @@ -79,7 +79,6 @@ import Ouroboros.Consensus.Node.NetworkProtocolVersion
import Ouroboros.Consensus.Node.ProtocolInfo
import qualified Ouroboros.Consensus.Node.Tracers as Consensus
import qualified Ouroboros.Consensus.Storage.LedgerDB.Args as LDBArgs
import Ouroboros.Consensus.Storage.LedgerDB.V2.Args
import Ouroboros.Consensus.Util.Args
import Ouroboros.Consensus.Util.Orphans ()

Expand Down Expand Up @@ -560,7 +559,7 @@ handleSimpleNode blockType runP tracers nc onKernel = do
, srnChainSyncIdleTimeout = customizeChainSyncTimeout
, srnSnapshotPolicyArgs = snapshotPolicyArgs
, srnQueryBatchSize = queryBatchSize
, srnLdbFlavorArgs = selectorToArgs ldbBackend
, srnLedgerDbBackendArgs = selectorToArgs ldbBackend (nonImmutableDbPath dbPath)
}
where
customizeChainSyncTimeout :: ChainSyncIdleTimeout
Expand Down
5 changes: 3 additions & 2 deletions cardano-node/src/Cardano/Node/TraceConstraints.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import Ouroboros.Consensus.Ledger.SupportsMempool (ApplyTxErr, HasTxId
import Ouroboros.Consensus.Node.NetworkProtocolVersion
(HasNetworkProtocolVersion (BlockNodeToClientVersion, BlockNodeToNodeVersion))
import Ouroboros.Consensus.Node.Run (RunNode, SerialiseNodeToNodeConstraints)
import Ouroboros.Consensus.Peras.SelectView
import Ouroboros.Consensus.Protocol.Abstract (SelectView, ValidationErr)
import Ouroboros.Consensus.Shelley.Ledger.Mempool (GenTx, TxId)
import Ouroboros.Network.Block (Serialised)
Expand Down Expand Up @@ -51,7 +52,7 @@ type TraceConstraints blk =
, ToObject (LedgerError blk)
, ToObject (LedgerEvent blk)
, ToObject (OtherHeaderEnvelopeError blk)
, ToObject (SelectView (BlockProtocol blk))
, ToObject (WeightedSelectView (BlockProtocol blk))
, ToObject (ValidationErr (BlockProtocol blk))
, ToObject (CannotForge blk)
, ToObject (ForgeStateUpdateError blk)
Expand All @@ -66,7 +67,7 @@ type TraceConstraints blk =
, LogFormatting (LedgerUpdate blk)
, LogFormatting (LedgerWarning blk)
, LogFormatting (OtherHeaderEnvelopeError blk)
, LogFormatting (SelectView (BlockProtocol blk))
, LogFormatting (WeightedSelectView (BlockProtocol blk))
, LogFormatting (ValidationErr (BlockProtocol blk))
, LogFormatting (CannotForge blk)
, LogFormatting (ForgeStateUpdateError blk)
Expand Down
12 changes: 7 additions & 5 deletions cardano-node/src/Cardano/Node/Tracing/Era/HardFork.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Cardano.Logging
import Cardano.Slotting.Slot (EpochSize (..))
import Cardano.Tracing.OrphanInstances.HardFork ()
import Ouroboros.Consensus.Block (BlockProtocol, CannotForge, ForgeStateInfo,
ForgeStateUpdateError)
ForgeStateUpdateError, PerasWeight (..))
import Ouroboros.Consensus.BlockchainTime (getSlotLength)
import Ouroboros.Consensus.Cardano.Condense ()
import Ouroboros.Consensus.HardFork.Combinator
Expand All @@ -36,7 +36,8 @@ import Ouroboros.Consensus.HeaderValidation (OtherHeaderEnvelopeError)
import Ouroboros.Consensus.Ledger.Abstract (LedgerError)
import Ouroboros.Consensus.Ledger.Inspect (LedgerUpdate, LedgerWarning)
import Ouroboros.Consensus.Ledger.SupportsMempool (ApplyTxErr)
import Ouroboros.Consensus.Protocol.Abstract (ValidationErr, TiebreakerView, SelectView(..))
import Ouroboros.Consensus.Peras.SelectView
import Ouroboros.Consensus.Protocol.Abstract (TiebreakerView, ValidationErr)
import Ouroboros.Consensus.TypeFamilyWrappers
import Ouroboros.Consensus.Util.Condense (Condense (..))

Expand Down Expand Up @@ -352,10 +353,11 @@ instance LogFormatting (ForgeStateUpdateError blk) => LogFormatting (WrapForgeSt
instance All (LogFormatting `Compose` WrapTiebreakerView) xs => LogFormatting (HardForkTiebreakerView xs) where
forMachine dtal = forMachine dtal . getHardForkTiebreakerView

instance LogFormatting (TiebreakerView protocol) => LogFormatting (SelectView protocol) where
instance LogFormatting (TiebreakerView protocol) => LogFormatting (WeightedSelectView protocol) where
forMachine dtal sv = mconcat
[ "blockNo" .= svBlockNo sv
, forMachine dtal (svTiebreakerView sv)
[ "blockNo" .= wsvBlockNo sv
, "weightBoost" .= unPerasWeight (wsvWeightBoost sv)
, forMachine dtal (wsvTiebreaker sv)
]

instance All (LogFormatting `Compose` WrapTiebreakerView) xs => LogFormatting (OneEraTiebreakerView xs) where
Expand Down
Loading
Loading