Skip to content

Commit

Permalink
Merge pull request #320 from input-output-hk/shelley-ma
Browse files Browse the repository at this point in the history
  • Loading branch information
disassembler committed Oct 22, 2020
2 parents 58deb30 + dba023c commit 37b427b
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 57 deletions.
2 changes: 2 additions & 0 deletions globals-defaults.nix
Expand Up @@ -14,6 +14,8 @@ in {

environmentName = pkgs.globals.deploymentName;

topology = import (./topologies + "/${pkgs.globals.environmentName}.nix") pkgs;

sourcesJsonOverride = ./nix + "/sources.${pkgs.globals.environmentName}.json";

dnsZone = "dev.cardano.org";
Expand Down
20 changes: 20 additions & 0 deletions globals-launchpad.nix
@@ -0,0 +1,20 @@
pkgs: {

deploymentName = "launchpad";

withFaucet = true;
withExplorer = true;
withCardanoDBExtended = true;
withSmash = false;
withSubmitApi = true;
faucetHostname = "faucet";

ec2 = {
credentials = {
accessKeyIds = {
IOHK = "default";
dns = "dev";
};
};
};
}
29 changes: 8 additions & 21 deletions globals-shelley-dev.nix
@@ -1,36 +1,23 @@
pkgs: rec {
pkgs: with pkgs; with iohkNix.cardanoLib; rec {

withMonitoring = false;
withExplorer = false;

environmentName = "shelley-dev";

environmentConfig = rec {
relays = "relays.${pkgs.globals.domain}";
edgeNodes = [
"18.197.234.239"
"3.125.14.209"
"52.58.137.138"
];
edgePort = pkgs.globals.cardanoNodePort;
genesisFile = ./keys/genesis.json;
genesisHash = builtins.replaceStrings ["\n"] [""] (builtins.readFile ./keys/GENHASH);
private = true;
networkConfig = pkgs.iohkNix.cardanoLib.environments.shelley_staging_short.networkConfig // {
GenesisHash = genesisHash;
NumCoreNodes = builtins.length topology.coreNodes;
nodeConfig = lib.recursiveUpdate environments.shelley_qa.nodeConfig {
ShelleyGenesisFile = genesisFile;
ShelleyGenesisHash = genesisHash;
Protocol = "TPraos";
TraceBlockFetchProtocol = true;
};
nodeConfig = pkgs.iohkNix.cardanoLib.environments.shelley_staging_short.nodeConfig // {
GenesisHash = genesisHash;
NumCoreNodes = builtins.length topology.coreNodes;
};
txSubmitConfig = {
inherit (networkConfig) RequiresNetworkMagic;
GenesisHash = genesisHash;
} // pkgs.iohkNix.cardanoLib.defaultExplorerLogConfig;
explorerConfig = mkExplorerConfig environmentName nodeConfig;
};

topology = import ./topologies/shelley-dev.nix;

ec2 = {
credentials = {
accessKeyIds = {
Expand Down
7 changes: 1 addition & 6 deletions modules/base-service.nix
Expand Up @@ -49,12 +49,7 @@ in

config = {

environment.systemPackages =
let completions = pkgs.runCommand "cardano-cli-completions" {} ''
mkdir -p $out/etc/bash_completion.d
${pkgs.cardano-cli}/bin/cardano-cli --bash-completion-script cardano-cli > $out/etc/bash_completion.d/cardano-cli
'';
in [ pkgs.cardano-cli completions ];
environment.systemPackages = [ pkgs.cardano-cli pkgs.cardano-cli-completions ];
environment.variables = {
CARDANO_NODE_SOCKET_PATH = cfg.socketPath;
};
Expand Down
6 changes: 6 additions & 0 deletions nix/cardano.nix
Expand Up @@ -12,4 +12,10 @@ in rec {
inherit (cardanoNodePkgs.cardanoNodeHaskellPackages.cardano-cli.components.exes) cardano-cli;
inherit (cardanoNodePkgs.cardanoNodeHaskellPackages.cardano-node.components.exes) cardano-node;
inherit (cardano-rosetta-pkgs) cardano-rosetta-server;

cardano-cli-completions = self.runCommand "cardano-cli-completions" {} ''
BASH_COMPLETIONS=$out/share/bash-completion/completions
mkdir -p $BASH_COMPLETIONS
${self.cardano-cli}/bin/cardano-cli --bash-completion-script cardano-cli > $BASH_COMPLETIONS/cardano-cli
'';
}
6 changes: 3 additions & 3 deletions nix/sources.json
Expand Up @@ -114,10 +114,10 @@
"homepage": null,
"owner": "input-output-hk",
"repo": "iohk-nix",
"rev": "edfa1fdbe68fe0023b1a9a231bb41e7a757cb829",
"sha256": "09366r2kprvaxx38y9qk05zxqcgkh89x34n6ck1hkvncjg6r9bfc",
"rev": "f0542228f98a2590e0f39c507b364321995ad802",
"sha256": "0yhgjg4bj7cv1lmrb9ig2iapv1mslhn6m750zn2x0n1a3ll267yh",
"type": "tarball",
"url": "https://github.com/input-output-hk/iohk-nix/archive/edfa1fdbe68fe0023b1a9a231bb41e7a757cb829.tar.gz",
"url": "https://github.com/input-output-hk/iohk-nix/archive/f0542228f98a2590e0f39c507b364321995ad802.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs-crystal": {
Expand Down
36 changes: 13 additions & 23 deletions shell.nix
Expand Up @@ -15,37 +15,22 @@ let
protocol."TPraos" = null;
in protocol.${globals.environmentConfig.nodeConfig.Protocol};

migrate-keys = writeShellScriptBin "migrate-keys" ''
i=0
for k in keys/*.sk; do
((i++))
signing_key=keys/delegate-keys.00$i.key
echo "migrating $k to $signing_key"
cardano-cli migrate-delegate-key-from --byron-legacy --from $k --real-pbft --to $signing_key
pk=$(cardano-cli signing-key-public --real-pbft --secret $signing_key | fgrep 'public key (base64):' | cut -d: -f2 | xargs echo -n)
delegate_cert=keys/delegation-cert.00$i.json
echo "generating delegation certificate for $pk in $delegate_cert"
${jq}/bin/jq ".heavyDelegation | .[] | select(.delegatePk == \"$pk\")" < ${toString genesisFile} > $delegate_cert
done
'';
create-shelley-genesis-and-keys =
let nbCoreNodes = builtins.length globals.topology.coreNodes;
maxSupply = 20000000000000000 * nbCoreNodes;
in writeShellScriptBin "create-shelley-genesis-and-keys" ''
set -euxo pipefail
mkdir -p keys
cd ${toString ./keys}
if [ ! -f genesis.spec.json ]; then
cp ../scripts/genesis.spec.json ./
fi
cardano-cli shelley genesis create --genesis-dir . --supply ${toString maxSupply} --gen-genesis-keys ${toString nbCoreNodes} --gen-utxo-keys ${toString nbCoreNodes}
cardano-cli shelley genesis create --genesis-dir . --supply ${toString maxSupply} --gen-genesis-keys ${toString nbCoreNodes} --gen-utxo-keys ${toString nbCoreNodes} --testnet-magic 42
cardano-cli shelley genesis hash --genesis genesis.json > GENHASH
mkdir -p node-keys
cd node-keys
for i in {1..${toString nbCoreNodes}}; do
cardano-cli shelley node key-gen-VRF --verification-key-file node-vrf$i.vkey --signing-key-file node-vrf$i.skey
cardano-cli shelley node key-gen-KES --verification-key-file node-kes$i.vkey --signing-key-file node-kes$i.skey
cardano-cli shelley node issue-op-cert --hot-kes-verification-key-file node-kes$i.vkey --cold-signing-key-file ../delegate-keys/delegate$i.skey --operational-certificate-issue-counter ../delegate-keys/delegate-opcert$i.counter --kes-period 0 --out-file node$i.opcert
ln -sf ../delegate-keys/delegate$i.vrf.skey node-vrf$i.skey
ln -sf ../delegate-keys/delegate$i.vrf.vkey node-vrf$i.vkey
done
${renew-kes-keys}/bin/new-KES-keys-at-period 0
'';
renew-kes-keys =
let nbCoreNodes = builtins.length globals.topology.coreNodes;
Expand All @@ -64,14 +49,13 @@ let
cd ${toString ./scripts}
cardano-cli --version
'';
in mkShell {
in mkShell rec {
buildInputs = [
cardano-cli
create-shelley-genesis-and-keys
dnsutils
iohkNix.niv
kes-rotation
migrate-keys
nivOverrides
nix
nix-diff
Expand All @@ -82,10 +66,16 @@ in mkShell {
renew-kes-keys
telnet
test-cronjob-script
cardano-cli-completions
];
XDG_DATA_DIRS = lib.concatStringsSep ":" (
[(builtins.getEnv "XDG_DATA_DIRS")] ++
(lib.filter builtins.pathExists (map (p: p + "/share") buildInputs))
);
NIX_PATH = "nixpkgs=${path}";
NIXOPS_DEPLOYMENT = "${globals.deploymentName}";
passthru = {
gen-graylog-creds = iohk-ops-lib.scripts.gen-graylog-creds { staticPath = ./static; };
};

}
62 changes: 62 additions & 0 deletions topologies/launchpad.nix
@@ -0,0 +1,62 @@
pkgs: with pkgs; with lib; with topology-lib;
let

regions = {
a = { name = "eu-central-1"; /* Europe (Frankfurt) */ };
b = { name = "us-east-2"; /* US East (Ohio) */ };
c = { name = "ap-southeast-1"; /* Asia Pacific (Singapore) */ };
};

bftCoreNodes = let
mkBftCoreNode = r: idx: attrs: (mkBftCoreNodeForRegions regions r idx attrs) // {
org = "IOHK";
producers = [{
addr = globals.relaysNew;
port = globals.cardanoNodePort;
valency = 3;
}];
};
in regionalConnectGroupWith (reverseList stakingPoolNodes)
(fullyConnectNodes [
# OBFT centralized nodes recovery nodes
(mkBftCoreNode "a" 1 {
nodeId = 1;
})
(mkBftCoreNode "b" 1 {
nodeId = 2;
})
(mkBftCoreNode "c" 1 {
nodeId = 3;
})
]);

stakingPoolNodes = [];

coreNodes = bftCoreNodes;

relayNodes = mkRelayTopology {
inherit regions coreNodes;
autoscaling = false;
};

in {

inherit coreNodes relayNodes;

monitoring = {
services.monitoring-services.publicGrafana = false;
};

"${globals.faucetHostname}" = {
services.cardano-faucet = {
anonymousAccess = false;
faucetLogLevel = "DEBUG";
secondsBetweenRequestsAnonymous = 86400;
secondsBetweenRequestsApiKeyAuth = 86400;
lovelacesToGiveAnonymous = 1000000000;
lovelacesToGiveApiKeyAuth = 10000000000;
useByronWallet = false;
};
};

}
8 changes: 4 additions & 4 deletions topologies/shelley-dev.nix
@@ -1,22 +1,22 @@
{
pkgs: with pkgs; with lib; with topology-lib; {
coreNodes = [
{
name = "a";
nodeId = 0;
nodeId = 1;
org = "IOHK";
region = "eu-central-1";
producers = ["b" "c"];
}
{
name = "b";
nodeId = 1;
nodeId = 2;
org = "IOHK";
region = "eu-central-1";
producers = ["c" "a"];
}
{
name = "c";
nodeId = 2;
nodeId = 3;
org = "IOHK";
region = "eu-central-1";
producers = ["a" "b"];
Expand Down

0 comments on commit 37b427b

Please sign in to comment.