Skip to content

Commit

Permalink
Set network env variables using mainnet if genesis.json not created yet.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbgi committed Apr 6, 2021
1 parent 3cb70b9 commit fecc642
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
10 changes: 7 additions & 3 deletions globals-defaults.nix
Expand Up @@ -57,7 +57,10 @@ in {
environmentVariables = optionalAttrs (builtins.pathExists ./globals.nix) (
let
genesisFile = globals.environmentConfig.nodeConfig.ShelleyGenesisFile;
genesis = builtins.fromJSON (builtins.readFile genesisFile);
genesis = builtins.fromJSON (builtins.readFile (if (builtins.pathExists genesisFile)
then genesisFile
# Use mainnet genesis as template to set network parameters if genesis does not exist yet:
else iohkNix.cardanoLib.environments.mainnet.nodeConfig.ShelleyGenesisFile));
bftNodes = filter (c: !c.stakePool) globals.topology.coreNodes;
stkNodes = filter (c: c.stakePool) globals.topology.coreNodes;
in rec {
Expand All @@ -72,14 +75,15 @@ in {

GENESIS_PATH = toString genesisFile;
# Network parameters.
SYSTEM_START = genesis.systemStart;
EPOCH_LENGTH = toString genesis.epochLength;
SLOT_LENGTH = toString genesis.slotLength;
K = toString genesis.securityParam;
F = toString genesis.activeSlotsCoeff;
MAX_SUPPLY = toString genesis.maxLovelaceSupply;
} // (optionalAttrs (builtins.pathExists genesisFile) {
SYSTEM_START = genesis.systemStart;
# End: Network parameters.
});
}));

deployerIp = requireEnv "DEPLOYER_IP";
cardanoNodePort = 3001;
Expand Down
11 changes: 11 additions & 0 deletions scripts/create-shelley-genesis-and-keys.sh
Expand Up @@ -22,6 +22,17 @@ cd "$(dirname "$0")/.."
[ -z ${K+x} ] && (echo "Environment variable K must be defined"; exit 1)
[ -z ${F+x} ] && (echo "Environment variable F must be defined"; exit 1)
[ -z ${MAX_SUPPLY+x} ] && (echo "Environment variable MAX_SUPPLY must be defined"; exit 1)
[ -z ${SLOT_LENGTH+x} ]&& ( echo "Environment variable SLOT_LENGTH must be defined"; exit 1)

echo "Generating new genesis and keys using following environments variables:
NB_BFT_NODES=$NB_BFT_NODES (number of bft core nodes)
NB_POOL_NODES=$NB_POOL_NODES (number of staking pool nodes)
K=$K (Security parameter)
F=$F (Active slots coefficient)
MAX_SUPPLY=$MAX_SUPPLY (Max Lovelace supply)
SLOT_LENGTH=$SLOT_LENGTH
"

export NB_CORE_NODES=$(($NB_BFT_NODES + $NB_POOL_NODES))

Expand Down

0 comments on commit fecc642

Please sign in to comment.