Skip to content

Commit b63c369

Browse files
committed
nix: LMDB via node config, not via CLI
1 parent a11e11e commit b63c369

File tree

2 files changed

+40
-30
lines changed

2 files changed

+40
-30
lines changed

nix/nixos/cardano-node-service.nix

+28-26
Original file line numberDiff line numberDiff line change
@@ -80,26 +80,33 @@ let
8080
})) cfg.extraNodeConfig;
8181
baseInstanceConfig =
8282
i:
83-
if !cfg.useLegacyTracing
84-
then baseConfig //
85-
{ ## XXX: remove once legacy tracing is dropped
86-
minSeverity = "Critical";
87-
setupScribes = [];
88-
setupBackends = [];
89-
defaultScribes = [];
90-
defaultBackends = [];
91-
options = {};
92-
}
93-
else baseConfig //
94-
{
95-
UseTraceDispatcher = false;
96-
} //
97-
(optionalAttrs (baseConfig ? hasEKG) {
98-
hasEKG = baseConfig.hasEKG + i;
99-
}) //
100-
(optionalAttrs (baseConfig ? hasPrometheus) {
101-
hasPrometheus = map (n: if isInt n then n + i else n) baseConfig.hasPrometheus;
102-
});
83+
( if !cfg.useLegacyTracing
84+
then baseConfig //
85+
{ ## XXX: remove once legacy tracing is dropped
86+
minSeverity = "Critical";
87+
setupScribes = [];
88+
setupBackends = [];
89+
defaultScribes = [];
90+
defaultBackends = [];
91+
options = {};
92+
}
93+
else baseConfig //
94+
{
95+
UseTraceDispatcher = false;
96+
} //
97+
(optionalAttrs (baseConfig ? hasEKG) {
98+
hasEKG = baseConfig.hasEKG + i;
99+
}) //
100+
(optionalAttrs (baseConfig ? hasPrometheus) {
101+
hasPrometheus = map (n: if isInt n then n + i else n) baseConfig.hasPrometheus;
102+
})
103+
)
104+
// optionalAttrs (cfg.withUtxoHdLmdb i){
105+
LedgerDB = {
106+
Backend = "V1LMDB";
107+
LiveTablesPath = cfg.lmdbDatabasePath i;
108+
};
109+
};
103110
in i: let
104111
instanceConfig = recursiveUpdate (baseInstanceConfig i) (cfg.extraNodeInstanceConfig i);
105112
nodeConfigFile = if (cfg.nodeConfigFile != null) then cfg.nodeConfigFile
@@ -133,10 +140,6 @@ let
133140
];
134141
};
135142
instanceDbPath = cfg.databasePath i;
136-
utxoLmdbParams = ["--utxos-on-disk"]
137-
++ lib.optionals (cfg.lmdbDatabasePath i != null)
138-
[ "--utxos-database-path ${cfg.lmdbDatabasePath i}"
139-
];
140143
cmd = builtins.filter (x: x != "") [
141144
"${cfg.executable} run"
142145
"--config ${nodeConfigFile}"
@@ -152,8 +155,7 @@ let
152155
"--tracer-socket-path-accept ${cfg.tracerSocketPathAccept i}"
153156
] ++ lib.optionals (cfg.tracerSocketPathConnect i != null) [
154157
"--tracer-socket-path-connect ${cfg.tracerSocketPathConnect i}"
155-
] ++ lib.optionals (cfg.withUtxoHdLmdb i) utxoLmdbParams
156-
++ consensusParams.${cfg.nodeConfig.Protocol} ++ cfg.extraArgs ++ cfg.rtsArgs;
158+
] ++ consensusParams.${cfg.nodeConfig.Protocol} ++ cfg.extraArgs ++ cfg.rtsArgs;
157159
in ''
158160
echo "Starting: ${concatStringsSep "\"\n echo \"" cmd}"
159161
echo "..or, once again, in a single line:"

nix/workbench/service/nodes.nix

+12-4
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ let
5353
then go {} (__head eras) (__tail eras)
5454
else throw "configHardforksIntoEra: unknown era '${era}'";
5555

56+
liveTablesPath = i:
57+
if (profile.cluster ? "ssd_directory" && profile.cluster.ssd_directory != null)
58+
then "${profile.cluster.ssd_directory}/lmdb-node-${toString i}"
59+
else null;
60+
5661
##
5762
## nodeServiceConfig :: NodeSpec -> ServiceConfig
5863
##
@@ -70,10 +75,7 @@ let
7075

7176
# Allow for local clusters to have multiple LMDB directories in the same physical ssd_directory
7277
withUtxoHdLmdb = profile.node.utxo_lmdb;
73-
lmdbDatabasePath =
74-
if (profile.cluster ? "ssd_directory" && profile.cluster.ssd_directory != null)
75-
then "${profile.cluster.ssd_directory}/lmdb-node-${toString i}"
76-
else null;
78+
lmdbDatabasePath = liveTablesPath i;
7779

7880
## Combine:
7981
## 0. baseNodeConfig (coming cardanoLib's testnet environ)
@@ -115,6 +117,12 @@ let
115117
ShelleyGenesisFile = "../genesis/genesis-shelley.json";
116118
AlonzoGenesisFile = "../genesis/genesis.alonzo.json";
117119
ConwayGenesisFile = "../genesis/genesis.conway.json";
120+
} // optionalAttrs profile.node.utxo_lmdb
121+
{
122+
LedgerDB = {
123+
Backend = "V1LMDB";
124+
LiveTablesPath = liveTablesPath i;
125+
};
118126
})
119127
(if __hasAttr "preset" profile && profile.preset != null
120128
## It's either an undisturbed preset,

0 commit comments

Comments
 (0)