From 3b3033688a4c28440e4437be8f213868a14bcfb8 Mon Sep 17 00:00:00 2001 From: John Lotoski Date: Mon, 2 Mar 2026 18:21:13 -0600 Subject: [PATCH 1/3] ci: add nixosTests for db tools vs node and cli compatibility --- flake.nix | 1 + nix/nixos/tests/cardano-node-dbtools.nix | 114 +++++++++++++++++++++++ nix/nixos/tests/default.nix | 3 + 3 files changed, 118 insertions(+) create mode 100644 nix/nixos/tests/cardano-node-dbtools.nix diff --git a/flake.nix b/flake.nix index dc681c499d5..70a1de22f5b 100644 --- a/flake.nix +++ b/flake.nix @@ -495,6 +495,7 @@ cardano-cli cardano-node cardano-submit-api + cardano-testnet cardano-tracer db-analyser db-synthesizer diff --git a/nix/nixos/tests/cardano-node-dbtools.nix b/nix/nixos/tests/cardano-node-dbtools.nix new file mode 100644 index 00000000000..001548dd1d8 --- /dev/null +++ b/nix/nixos/tests/cardano-node-dbtools.nix @@ -0,0 +1,114 @@ +{pkgs, ...}: let + inherit (lib) getExe; + inherit (pkgs) cardanoNodePackages lib; + + # NixosTest script fns supporting a timeout have a default of 900 seconds. + # + # There is no pre-existing history for chain synthesis, and default + # cardano-testnet genesis parameters set epochs to be short and fast, so a 30 + # second global timeout should be more than sufficient. + globalTimeout = 30; + + testDir = "testnet"; +in { + inherit globalTimeout; + + name = "cardano-node-dbtools-test"; + nodes = { + machine = _: { + nixpkgs.pkgs = pkgs; + + environment = { + systemPackages = with cardanoNodePackages; [ + cardano-cli + cardano-node + cardano-testnet + db-analyser + db-synthesizer + db-truncater + ] ++ (with pkgs; [ + gnugrep + ]); + + variables = { + CARDANO_CLI = getExe cardanoNodePackages.cardano-cli; + CARDANO_NODE = getExe cardanoNodePackages.cardano-node; + KES_KEY = "${testDir}/pools-keys/pool1/kes.skey"; + OPCERT = "${testDir}/pools-keys/pool1/opcert.cert"; + VRF_KEY = "${testDir}/pools-keys/pool1/vrf.skey"; + }; + }; + + # The default disk size of 1024 MB is insufficient for the binary artifact + # and tar gzip expansion. + virtualisation.diskSize = 2048; + }; + }; + + testScript = '' + import re + countRegex = r'Counted (\d+) blocks\.' + + start_all() + print(machine.succeed("cardano-node --version")) + print(machine.succeed("cardano-cli --version")) + print(machine.succeed("cardano-testnet version")) + print(machine.succeed("cardano-testnet create-env --output ${testDir}")) + + # TODO: Until db-synthesizer is fixed upstream + # print(machine.succeed("db-synthesizer \ + # --config ${testDir}/configuration.yaml \ + # --db db \ + # --shelley-operational-certificate $OPCERT \ + # --shelley-vrf-key $VRF_KEY \ + # --shelley-kes-key $KES_KEY \ + # --epochs 1 \ + # 2>&1") + + print(machine.succeed("echo Analyze synthesized chain")) + out = machine.succeed("db-analyser \ + --db db \ + --verbose \ + --count-blocks \ + --v2-in-mem \ + --config ${testDir}/configuration.yaml \ + 2>&1" + ) + print(out) + match = re.search(countRegex, out) + assert match is not None, f"Could not find block count in post-synthesis output: {out}" + blocks_before = int(match.group(1)) + print(f"Found {blocks_before} blocks post synthesis") + + # TODO: Until db-synthesizer is fixed upstream + # assert blocks_before > 0, f"No blocks were synthesized: {blocks_before}" + + print(machine.succeed("echo Truncate synthesized chain")) + print(machine.succeed("db-truncater \ + --db db \ + --truncate-after-block 1 \ + --verbose \ + --config ${testDir}/configuration.yaml \ + 2>&1") + ) + + print(machine.succeed("echo Analyze truncated chain")) + out = machine.succeed("db-analyser \ + --db db \ + --verbose \ + --count-blocks \ + --v2-in-mem \ + --config ${testDir}/configuration.yaml \ + 2>&1" + ) + print(out) + match = re.search(countRegex, out) + assert match is not None, f"Could not find block count in post-truncation output: {out}" + blocks_after = int(match.group(1)) + print(f"Found {blocks_after} blocks post truncation") + + # TODO: Until db-synthesizer is fixed upstream + # assert blocks_after == 1, f"Expected exactly 1 block after truncation, got {blocks_after}" + # assert blocks_before > blocks_after, f"Pre-truncation blockHeight of {blocks_before} should be larger than post-truncation blockHeight of {blocks_after}" + ''; +} diff --git a/nix/nixos/tests/default.nix b/nix/nixos/tests/default.nix index ad54ec401c6..c058a7d00e3 100644 --- a/nix/nixos/tests/default.nix +++ b/nix/nixos/tests/default.nix @@ -25,6 +25,9 @@ in { # Tests the linux release binary envs with pre-bundled config. cardanoNodeArtifact = callTest ./cardano-node-artifact.nix {inherit cardano-node-linux;}; + # Tests db-tools (synthesizer, analyser, truncater) against a cardano-testnet create-env environment. + cardanoNodeDbtools = callTest ./cardano-node-dbtools.nix {}; + # Tests a mainnet edge node with submit-api using nixos service config. cardanoNodeEdge = callTest ./cardano-node-edge.nix {}; } From 56ef9dfc5f32641e0c1eb4e14dc3a17fe6450a98 Mon Sep 17 00:00:00 2001 From: John Lotoski Date: Mon, 2 Mar 2026 19:14:13 -0600 Subject: [PATCH 2/3] releaseBins: add kes-agent for linux arches only --- flake.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 70a1de22f5b..fd2f23f2099 100644 --- a/flake.nix +++ b/flake.nix @@ -119,6 +119,7 @@ # Add some executables from other relevant packages inherit (bech32.components.exes) bech32; inherit (ouroboros-consensus-cardano.components.exes) db-analyser db-synthesizer db-truncater snapshot-converter; + inherit (kes-agent.components.exes) kes-agent kes-agent-control kes-service-client-demo; # Add cardano-node, cardano-cli and tx-generator with their git revision stamp. # Keep available an alternative without the git revision, like the other # passthru (profiled and asserted in nix/haskell.nix) that @@ -297,10 +298,15 @@ "db-analyser" "db-synthesizer" "db-truncater" + "kes-agent" + "kes-agent-control" "snapshot-converter" "tx-generator" ]; + # Binaries only supported on Linux; excluded from Windows and Darwin releases. + linuxOnlyBins = ["kes-agent" "kes-agent-control"]; + ciJobsVariants = mapAttrs ( _: p: @@ -368,7 +374,7 @@ inherit (exes.cardano-node.identifier) version; platform = "win"; exes = collect isDerivation ( - filterAttrs (n: _: elem n releaseBins) projectExes + filterAttrs (n: _: elem n releaseBins && !(elem n linuxOnlyBins)) projectExes ); }; internal.roots.project = windowsProject.roots; @@ -388,7 +394,7 @@ inherit (exes.cardano-node.identifier) version; platform = "macos"; exes = collect isDerivation ( - filterAttrs (n: _: elem n releaseBins) (collectExes project) + filterAttrs (n: _: elem n releaseBins && !(elem n linuxOnlyBins)) (collectExes project) ); }; shells = removeAttrs devShells ["profiled"]; From 9675da891a932885f672ec9708f4cd9077995c05 Mon Sep 17 00:00:00 2001 From: John Lotoski Date: Tue, 3 Mar 2026 16:43:41 -0600 Subject: [PATCH 3/3] ci: rm unneeded deps, sizing for the db tools test --- nix/nixos/tests/cardano-node-dbtools.nix | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/nix/nixos/tests/cardano-node-dbtools.nix b/nix/nixos/tests/cardano-node-dbtools.nix index 001548dd1d8..46418f8516e 100644 --- a/nix/nixos/tests/cardano-node-dbtools.nix +++ b/nix/nixos/tests/cardano-node-dbtools.nix @@ -26,9 +26,7 @@ in { db-analyser db-synthesizer db-truncater - ] ++ (with pkgs; [ - gnugrep - ]); + ]; variables = { CARDANO_CLI = getExe cardanoNodePackages.cardano-cli; @@ -38,10 +36,6 @@ in { VRF_KEY = "${testDir}/pools-keys/pool1/vrf.skey"; }; }; - - # The default disk size of 1024 MB is insufficient for the binary artifact - # and tar gzip expansion. - virtualisation.diskSize = 2048; }; };