Skip to content

[DDW-1116] Use cardano-node with UTxO HD enabled #3005

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

Closed
wants to merge 5 commits into from
Closed
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
34 changes: 13 additions & 21 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
, HSMServer ? null
, fudgeConfig ? null
, devShell ? false
, useLocalNode ? false
, useCustomNode ? true
, topologyOverride ? null
, configOverride ? null
, genesisOverride ? null
Expand Down Expand Up @@ -53,9 +53,14 @@ let
aarch64-darwin = macos.silicon;
}.${target};
walletPkgs = walletFlake.legacyPackages.${system}.pkgs;
customNodeFlake = (flake-compat { src = sources.custom-cardano-node; }).defaultNix;
customNodePackages = {
x86_64-windows = customNodeFlake.hydraJobs.linux.windows;
x86_64-linux = customNodeFlake.hydraJobs.linux.native;
x86_64-darwin = customNodeFlake.hydraJobs.macos;
aarch64-darwin = customNodeFlake.packages.aarch64-darwin;
}.${target};
cardanoWorldFlake = (flake-compat { src = sources.cardano-world; }).defaultNix.outputs;
# only used for CLI, to be removed when upgraded to next node version
nodePkgs = import "${sources.cardano-node}/nix" {};
shellPkgs = (import "${sources.cardano-shell}/nix") { inherit system; };
inherit (pkgs.lib) optionalString;
crossSystem = lib: (crossSystemTable lib).${target} or null;
Expand All @@ -71,7 +76,7 @@ let
ostable.aarch64-darwin = "macos64-arm";

packages = self: {
inherit walletFlake cardanoWorldFlake cluster pkgs version target nodeImplementation;
inherit walletFlake customNodeFlake cardanoWorldFlake cluster pkgs version target nodeImplementation;
cardanoLib = walletPkgs.cardanoLib;
daedalus-bridge = self.bridgeTable.${nodeImplementation};

Expand Down Expand Up @@ -113,24 +118,11 @@ let
inherit (walletPackages) mock-token-metadata-server;
cardano-shell = import self.sources.cardano-shell { inherit system; crossSystem = crossSystem shellPkgs.lib; };
local-cluster = if cluster == "selfnode" then walletPackages.local-cluster else null;
cardano-node-cluster = let
# Test wallets with known mnemonics
walletTestGenesisYaml = (self.sources.cardano-wallet + "/lib/shelley/test/data/cardano-node-shelley/genesis.yaml");
walletTestGenesisJson = pkgs.runCommand "yaml-to-json" { buildInputs = [self.yaml2json]; } ''
yaml2json ${walletTestGenesisYaml} > $out
'';
initialFundsAttrs = (__fromJSON (__readFile walletTestGenesisJson)).initialFunds;
# Funds required to register pools
clusterFunds = import (self.sources.cardano-node + "/nix/supervisord-cluster/initial-funds.nix");
customConfig = {
initialFunds = clusterFunds // __foldl' (s: x: s // x) {} initialFundsAttrs;
};
in (import self.sources.cardano-node { inherit system customConfig; crossSystem = crossSystem nodePkgs.lib; }).cluster;
cardano-node = if useLocalNode
then (import self.sources.cardano-node { inherit system; crossSystem = crossSystem nodePkgs.lib; }).cardano-node
cardano-node = if useCustomNode
then customNodePackages.cardano-node
else walletPackages.cardano-node;
cardano-cli = if useLocalNode
then (import self.sources.cardano-node { inherit system; crossSystem = crossSystem nodePkgs.lib; }).haskellPackages.cardano-cli
cardano-cli = if useCustomNode
then customNodePackages.cardano-cli
else walletPackages.cardano-cli;
darwin-launcher = self.callPackage ./nix/darwin-launcher.nix {};

Expand Down
2 changes: 2 additions & 0 deletions installers/common/WindowsInstaller.hs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ writeInstallerNSIS outName (Version fullVersion') InstallerConfig{installDirecto
file [] "genesis-alonzo.json"
file [] "libsodium-23.dll"
file [] "libsecp256k1-0.dll"
file [] "libcrypto-3-x64.dll"
file [] "libssl-3-x64.dll"
when (clusterName == Selfnode) $ do
file [] "signing.key"
file [] "delegation.cert"
Expand Down
4 changes: 4 additions & 0 deletions nix/cardano-bridge.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ runCommandCC "daedalus-cardano-bridge" {
cp -f ${cardano-address}/bin/cardano-address* .
cp -f ${cardano-shell.haskellPackages.cardano-launcher.components.exes.cardano-launcher}/bin/* .
cp -f ${cardano-node}/bin/cardano-node* .
${if target == "x86_64-windows" then ''
cp -f ${cardano-node}/bin/libcrypto-3-x64.dll .
cp -f ${cardano-node}/bin/libssl-3-x64.dll .
'' else ""}
cp -f ${cardano-cli}/bin/cardano-cli* .
${lib.optionalString (local-cluster != null) ''

Expand Down
9 changes: 8 additions & 1 deletion nix/launcher-config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,13 @@ let
${lib.optionalString (envCfg.nodeConfig ? AlonzoGenesisFile) "cp ${envCfg.nodeConfig.AlonzoGenesisFile} $out/genesis-alonzo.json"}
'';

# cf. <https://github.com/input-output-hk/cardano-node/blob/b8f6178aa5e5c38baee997e338d824b086ec54e7/doc/getting-started/understanding-config-files.md#ledger-state-on-disk>
utxoHDAttrs = {
# LedgerDBBackend = "InMemory";
LedgerDBBackend = "LMDB";
LMDBMapSize = 16;
};

mkConfigCardano = let
filterMonitoring = config: if devShell then config else builtins.removeAttrs config [ "hasPrometheus" "hasEKG" ];
cardanoAddressBin = mkBinPath "cardano-address";
Expand All @@ -244,7 +251,7 @@ let
cliBin = mkBinPath "cardano-cli";
nodeConfig = let
nodeConfigAttrs = if (configOverride == null) then envCfg.nodeConfig else __fromJSON (__readFile configOverride);
in builtins.toJSON (filterMonitoring (nodeConfigAttrs // (lib.optionalAttrs (!isDevOrLinux || network == "local") {
in builtins.toJSON (filterMonitoring (nodeConfigAttrs // utxoHDAttrs // (lib.optionalAttrs (!isDevOrLinux || network == "local") {
ByronGenesisFile = "genesis-byron.json";
ShelleyGenesisFile = "genesis-shelley.json";
AlonzoGenesisFile = "genesis-alonzo.json";
Expand Down
10 changes: 5 additions & 5 deletions nix/sources.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"cardano-node": {
"branch": "tags/1.35.4",
"custom-cardano-node": {
"branch": "consensus/feature/utxo-hd-test-release",
"description": null,
"homepage": null,
"owner": "input-output-hk",
"repo": "cardano-node",
"rev": "ebc7be471b30e5931b35f9bbc236d21c375b91bb",
"sha256": "1j01m2cp2vdcl26zx9xmipr551v3b2rz9kfn9ik8byfwj1z7652r",
"rev": "033236e688b296f1ffe792e95ea8d174d39c272e",
"sha256": "0ssxikk9xjgb1lllfcr5w2fvl9cx15gdwg9gw2ayv703kk1p8w2b",
"type": "tarball",
"url": "https://github.com/input-output-hk/cardano-node/archive/ebc7be471b30e5931b35f9bbc236d21c375b91bb.tar.gz",
"url": "https://github.com/input-output-hk/cardano-node/archive/033236e688b296f1ffe792e95ea8d174d39c272e.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"cardano-shell": {
Expand Down
7 changes: 3 additions & 4 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
, topologyOverride ? null
, configOverride ? null
, genesisOverride ? null
, useLocalNode ? false
, nivOnly ? false
, useCustomNode ? true
}:

let
daedalusPkgs = import ./. {
inherit nodeImplementation cluster topologyOverride configOverride genesisOverride useLocalNode;
inherit nodeImplementation cluster topologyOverride configOverride genesisOverride useCustomNode;
target = system;
localLibSystem = system;
devShell = true;
Expand Down Expand Up @@ -195,7 +194,7 @@ let
name = "devops-shell";
buildInputs = let
inherit (daedalusPkgs.walletFlake.outputs.legacyPackages.${system}.pkgs) niv;
in if nivOnly then [ niv ] else [ niv daedalusPkgs.cardano-node-cluster.start daedalusPkgs.cardano-node-cluster.stop ];
in niv;
shellHook = ''
export CARDANO_NODE_SOCKET_PATH=$(pwd)/state-cluster/bft1.socket
echo "DevOps Tools" \
Expand Down