Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

[release/1.3.1] [DEVOPS-398] Testnet config #3585

Merged
merged 6 commits into from
Sep 26, 2018
Merged
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
6 changes: 6 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ let
validateJson = pkgs.callPackage ./tools/src/validate-json {};
demoCluster = pkgs.callPackage ./scripts/launch/demo-cluster { inherit gitrev; };
demoClusterDaedalusDev = pkgs.callPackage ./scripts/launch/demo-cluster { inherit gitrev; disableClientAuth = true; numImportedWallets = 0; };
demoClusterLaunchGenesis = pkgs.callPackage ./scripts/launch/demo-cluster {
inherit gitrev;
launchGenesis = true;
configurationKey = "testnet_full";
runWallet = false;
};
shellcheckTests = pkgs.callPackage ./scripts/test/shellcheck.nix { src = ./.; };
swaggerSchemaValidation = pkgs.callPackage ./scripts/test/wallet/swaggerSchemaValidation.nix { inherit gitrev; };
walletIntegrationTests = pkgs.callPackage ./scripts/test/wallet/integration { inherit gitrev; };
Expand Down
115 changes: 115 additions & 0 deletions docs/how-to/launch-testnet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# How to launch a testnet

This document explains how the Cardano SL public testnet was launched
and the configuration settings used.

Related documents:

* [`how-to/generate-genesis.md`](./generate-genesis.md)
* [`how-to/connect-to-cluster.md`](./connect-to-cluster.md)
* [`configuration.md`](../configuration.md)

## Genesis Data

A new genesis block is created for the testnet. The parameters used to
generate genesis data are specified in the `testnet_launch` section of
[`lib/configuration.yaml`](../../lib/configuration.yaml).

All values are inherited from the `mainnet_base` section, unless
overridden.

### Initializer

* `protocolMagic` -- this number is different from mainnet's magic to
ensure that signatures from testnet are different to mainnet.
* `requiresNetworkMagic` -- `NMMustBeJust` (the default) -- will
ensure that the format of addresses and hence transactions are
different and incompatible to those of mainnet.
* `totalBalance` -- 42,000,000,000 Ada -- is close to the maximum
possible coin value (45B Ada).
* `avvmDistr` -- this is the empty hashmap, unlike in mainnet which
has many Ada redemption addresses.
* `fakeAvvmBalances` -- there are 100 fake AVVM seeds which can be
used to redeem 20,000,000 Ada each on the testnet.
* `poors` -- Unlike mainnet which has none, there are 100 "poor"
nodes with generated keys.
* `richmen` -- There are 7 testnet richmen, i.e. core nodes, same as
mainnet.
* `richmenShare` -- 95%. After subtracting the total balance of fake
AVVM certificates, there will be 40,000,000,000 Ada divided between
the 7 rich and 100 poor nodes. A single poor node will recieve
0.05% of that total, which is 20,000,000 Ada.

### `blockVersionData`

The mainnet `blockVersionData` has been updated since its genesis. The
testnet will be launched with these new parameters matching mainnet's
current `blockVersionData`.

| `blockVersionData` | Value | Description |
| :----------------- | ----: | :------------------------------------------|
| `maxHeaderSize` | 2KB | Maximum size of block's header |
| `maxProposalSize` | 70KB | Maximum size of Cardano SL update proposal |
| `maxTxSize` | 64KiB | Maximum size of transaction |

### Update system block version

In addition, the `update.lastKnownBlockVersion` is set at `0.0.0` in
the `testnet_full`. The nodes will refuse to create blocks if this
value is higher than zero.

## Faucet

The testnet faucet will dispense a random amount in the range of 500
to 1500 Ada.

It is not rate limited, but automatic withdrawals are prevented with
[reCAPTCHA](https://developers.google.com/recaptcha/).

According to the parameters above, up to 2,000,000,000 Ada could be
dispensed, though not all should be made available to the faucet.

## Maintaining control of testnet Ada

IOHK will retain control of the majority of testnet Ada to minimise
the risk of the testnet becoming a threat blockchain and the testnet
currency assuming value.

The core nodes (richmen) control 95% of stake.

Additionally, not all AVVM certificates and "poor" addresses should be
sent to the faucet.

## Redeeming ADA from fake AVVM seeds

The certificate seeds are in the `keys-fakeavvm` directory within the
output of `cardano-keygen generate-keys-by-spec`.

Copy one of `fake-N.seed` to the clipboard, then use the Daedalus
wallet UI to redeem the testnet Ada.

1. Click on the _Daedalus_ → _Ada redemption_ menu
2. Go to the _Regular_ tab
3. Paste the seed into the _Redemption key_ box.

## Importing "poor" secret keys into a wallet

Copy one of `generated-keys/poor/keyN.sk` to a secure location and
then use the v0 `/api/wallets/keys` endpoint to import it into a
wallet.

## Launching a demo cluster with testnet genesis

This script will generate genesis data using the procedure described
in [`configuration.md`](../configuration.md), and then launch a demo
cluster with that genesis data.

nix-build -A demoClusterLaunchGenesis -o demo-cluster-launch-genesis.sh
./demo-cluster-launch-genesis.sh

## Connecting to the testnet

This script will connect to the running public testnet.

nix-build -A connectScripts.testnet.wallet -o connect-testnet-wallet.sh
./connect-testnet-wallet.sh
8 changes: 4 additions & 4 deletions lib/configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15027,7 +15027,7 @@ devnet: &devnet
useHeavyDlg: True
seed: 0

update:
update: &devnet_update
applicationName: cardano-sl
applicationVersion: 0
lastKnownBlockVersion:
Expand All @@ -15044,7 +15044,7 @@ devnet: &devnet
devnet_win64:
<<: *devnet
update:
<<:
<<: *devnet_update
applicationName: csl-daedalus
applicationVersion: 0
lastKnownBlockVersion:
Expand All @@ -15056,7 +15056,7 @@ devnet_win64:
devnet_macos64:
<<: *devnet
update:
<<:
<<: *devnet_update
applicationName: csl-daedalus
applicationVersion: 0
lastKnownBlockVersion:
Expand All @@ -15068,7 +15068,7 @@ devnet_macos64:
devnet_linux64:
<<: *devnet
update:
<<:
<<: *devnet_update
applicationName: csl-daedalus
applicationVersion: 0
lastKnownBlockVersion:
Expand Down
2 changes: 2 additions & 0 deletions scripts/common-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ function node_cmd {
keys_args="--genesis-secret $i"
if [[ "$CSL_PRODUCTION" != "" ]]; then
keys_args="--keyfile \"secrets/secret-$((i+1)).key\""
elif [[ "$DEMO_GENESIS_KEYS_DIR" != "" ]]; then
keys_args="--keyfile \"$DEMO_GENESIS_KEYS_DIR/key$i.sk\""
fi

if [[ $NO_REBUILD == "" ]]; then
Expand Down
19 changes: 9 additions & 10 deletions scripts/launch/connect-to-cluster/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
, system ? builtins.currentSystem
, pkgs ? import localLib.fetchNixPkgs { inherit system config; }
, gitrev ? localLib.commitIdFromGitRepo ./../../../.git
, walletListen ? "127.0.0.1:8090"
, walletDocListen ? "127.0.0.1:8091"
, ekgListen ? "127.0.0.1:8000"
, walletListen ? "localhost:8090"
, walletDocListen ? "localhost:8091"
, ekgListen ? "localhost:8000"
, ghcRuntimeArgs ? "-N2 -qg -A1m -I0 -T"
, additionalNodeArgs ? ""
, confFile ? null
, confKey ? null
, relays ? null
, debug ? false
Expand Down Expand Up @@ -46,7 +47,7 @@ let
relays = "127.0.0.1";
};
override = {
inherit relays confKey;
inherit relays confKey confFile;
};
};
executables = {
Expand Down Expand Up @@ -94,14 +95,12 @@ in pkgs.writeScript "${executable}-connect-to-${environment}" ''
${iohkPkgs.cardano-sl-tools}/bin/cardano-x509-certificates \
--server-out-dir ${stateDir}/tls/server \
--clients-out-dir ${stateDir}/tls/client \
--configuration-key ${environments.${environment}.confKey} \
--configuration-file ${configFiles}/lib/configuration.yaml
${configurationArgs}
fi
''}

exec ${executables.${executable}} \
--configuration-file ${configFiles}/lib/configuration.yaml \
--configuration-key ${environments.${environment}.confKey} \
exec ${executables.${executable}} \
${configurationArgs} \
${ ifWallet "--tlscert ${stateDir}/tls/server/server.crt"} \
${ ifWallet "--tlskey ${stateDir}/tls/server/server.key"} \
${ ifWallet "--tlsca ${stateDir}/tls/server/ca.crt"} \
Expand All @@ -119,4 +118,4 @@ in pkgs.writeScript "${executable}-connect-to-${environment}" ''
+RTS ${ghcRuntimeArgs} -RTS \
${additionalNodeArgs} \
$RUNTIME_ARGS
''
'' // { inherit walletListen walletDocListen ekgListen; }
Loading