Skip to content
Permalink
Browse files

A standalone cardano-node-legacy node, with a proxy following it

  • Loading branch information...
deepfire committed Oct 9, 2019
1 parent d335adf commit a21fdd9f790b2a4d7d74907dba2a63475f3839e4
Showing with 66 additions and 16 deletions.
  1. +1 −1 default.nix
  2. +18 −10 modules/cardano-service.nix
  3. +37 −5 tests/cluster-in-virtualbox/cluster.nix
  4. +10 −0 topology-isolated-relay.yaml
@@ -43,7 +43,7 @@ let
gitrev = cardano-sl-src.rev;
};
mantis-pkgs = commonLib.fetchProjectPackages "mantis" <mantis> ./goguen/pins mantisRevOverride args;
cardano-node-srcs = sources.cardano-node.revOverride cardanoNodeRevOverride;
cardano-node-srcs = ../cardano-node;
cardano-node-pkgs = import cardano-node-srcs {};

iohk-ops = pkgs.haskell.lib.overrideCabal
@@ -1,6 +1,5 @@
with import ../lib.nix;

{ config, pkgs, lib, options, ... }:
with lib;
let
cfg = config.services.cardano-node-legacy;
name = "cardano-node";
@@ -14,9 +13,9 @@ let

command = toString [
cfg.executable
(optionalString (cfg.publicIP != null && config.params.name != "explorer")
(optionalString (cfg.publicIP != null && cfg.name != "explorer")
"--address ${cfg.publicIP}:${toString cfg.port}")
(optionalString (config.params.name != "explorer")
(optionalString (cfg.name != "explorer")
"--listen ${cfg.privateIP}:${toString cfg.port}")
# Profiling
# NB. can trigger https://ghc.haskell.org/trac/ghc/ticket/7836
@@ -37,9 +36,9 @@ let
(optionalString cfg.jsonLog "--json-log ${stateDir}/jsonLog.json")
(optionalString (cfg.statsdServer != null) "--metrics +RTS -T -RTS --statsd-server ${cfg.statsdServer}")
(optionalString (cfg.serveEkg) "--ekg-server ${cfg.privateIP}:8080")
(optionalString (cfg.productionMode && config.params.name != "explorer")
(optionalString (cfg.productionMode && cfg.name != "explorer")
"--keyfile ${stateDir}/key${toString cfg.nodeIndex}.sk")
(optionalString (cfg.productionMode && config.global.systemStart != 0) "--system-start ${toString config.global.systemStart}")
(optionalString (cfg.productionMode && cfg.systemStart != 0) "--system-start ${toString cfg.systemStart}")
(optionalString cfg.supporter "--supporter")
"--log-config ${cardano-config}/log-configs/cluster.yaml"
"--logs-prefix /var/lib/cardano-node"
@@ -49,17 +48,21 @@ let
"--configuration-key ${config.deployment.arguments.configurationKey}"
"--topology ${cfg.topologyYaml}"
(optionalString (cfg.assetLockFile != null) "--asset-lock-file ${cfg.assetLockFile}")
"--node-id ${config.params.name}"
(optionalString cfg.enablePolicies ("--policies " + (if (config.params.typeIsCore) then "${../benchmarks/policy_core.yaml}" else "${../benchmarks/policy_relay.yaml}")))
"--node-id ${cfg.name}"
(optionalString cfg.enablePolicies ("--policies " + (if cfg.nodeType == "core" then "${../benchmarks/policy_core.yaml}" else "${../benchmarks/policy_relay.yaml}")))
(optionalString cfg.enableProfiling "+RTS -p -RTS")
];
in {
options = {
services.cardano-node-legacy = {
name = mkOption { type = types.str; };

enable = mkEnableOption name;
port = mkOption { type = types.int; default = 3000; };
systemStart = mkOption { type = types.int; default = 0; };

preseedDB = mkOption { type = types.nullOr types.path; default = null; };

enableP2P = mkOption { type = types.bool; default = true; };
supporter = mkOption { type = types.bool; default = false; };
enableProfiling = mkOption { type = types.bool; default = false; };
@@ -145,8 +148,6 @@ in {
};

config = mkIf cfg.enable {
services.cardano-node-legacy.serveEkg = config.global.enableEkgWeb;

assertions = [
{ assertion = cfg.nodeType != null;
message = "services.cardano-node-legacy.type must be set to one of: core relay other"; }
@@ -193,6 +194,13 @@ in {
description = "cardano node service";
after = [ "network.target" ];
wantedBy = optionals cfg.autoStart [ "multi-user.target" ];
preStart = optionalString (cfg.preseedDB != null) ''
if test ! -d ${stateDir}/node-db
then cp ${cfg.preseedDB} ${stateDir}/node-db -r
chown cardano-node ${stateDir}/node-db -R
chmod u+w cardano-node ${stateDir}/node-db -R
fi
'';
script = let
key = "key${toString cfg.nodeIndex}.sk";
in ''
@@ -1,4 +1,5 @@
let
sources = import ../../nix/sources.nix;
inherit (import ../.. {}) cardano-node-pkgs cardano-node-srcs;
in
{
@@ -8,17 +9,48 @@ in
deployment.virtualbox.memorySize = 1024;
};

a-node = { pkgs, ... }: {
a-node = { pkgs, config, lib, ... }: with builtins; with lib; {
imports = [
(cardano-node-srcs + "/nix/nixos/cardano-node-service.nix")
(cardano-node-srcs + "/nix/nixos/cardano-cluster-service.nix")
(cardano-node-srcs + "/nix/nixos/chairman-as-a-service.nix")
# (cardano-node-srcs + "/nix/nixos/cardano-node-legacy-service.nix")
(sources.cardano-byron-proxy + "/nix/nixos")
../../modules/cardano-service.nix
];
# services.cardano-node.enable = true;
services.chairman.enable = true;
services.cardano-cluster = {
services.dnsmasq.enable = true;
services.dnsmasq.servers = [ "127.0.0.1" ];
services.cardano-node-legacy = {
enable = true;
node-count = 3;
nodeType = "relay";
nodeIndex = 0;
name = "r-a-1";
systemStart = 1506203091;
topologyYaml = ../../topology-isolated-relay.yaml;
preseedDB = pkgs.runCommand "node-db-seed" {} ''
mkdir $out
tar xaf ${../../static/node-db.mainnet.tar.xz} -C $out
'';
};
networking.extraHosts = ''
127.0.0.1 r-a-1.cardano
'';
deployment.arguments.configurationKey = "mainnet_full";

services.byron-proxy = {
enable = true;
environment = "mainnet";
topologyFile = toFile "proxy-topology.yaml" ''
wallet:
relays: [[{ host: r-a-1.cardano }]]
'';
};

# services.cardano-node.enable = true;
# services.chairman.enable = true;
# services.cardano-cluster = {
# enable = true;
# node-count = 3;
# };
};
}
@@ -0,0 +1,10 @@
nodes:
'r-a-1':
region: ap-northeast-1
zone: ap-northeast-1a
type: relay
org: IOHK
host: r-a-1.cardano
kademlia: false
public: true
static-routes: [['r-a-1']]

0 comments on commit a21fdd9

Please sign in to comment.
You can’t perform that action at this time.