Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hetzner template - preview #44

Draft
wants to merge 7 commits into
base: aciceri/update-cardano
Choose a base branch
from
Draft
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: 3 additions & 3 deletions apps/testnet-template/configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ RequiresNetworkMagic: RequiresMagic
# This protocol version number gets used by block producing nodes as part
# of the system for agreeing on and synchronising protocol updates.
LastKnownBlockVersion-Alt: 0
LastKnownBlockVersion-Major: 8
LastKnownBlockVersion-Minor: 0
LastKnownBlockVersion-Major: 3
LastKnownBlockVersion-Minor: 1

# In the Byron era some software versions are also published on the chain.
# We do this only for Byron compatibility now.
Expand Down Expand Up @@ -301,5 +301,5 @@ TestMaryHardForkAtEpoch: 0
TestAlonzoHardForkAtEpoch: 0
TestBabbageHardForkAtEpoch: 0
TestConwayHardForkAtEpoch: 0
ExperimentalProtocolsEnabled: True
ExperimentalProtocolsEnabled: False
EnableP2P: True
1 change: 1 addition & 0 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ nav:
- Getting Started:
- Overview: getting-started/overview.md
- Usage:
- Setup: usage/setup.md
- Configure pool: usage/configure-pool.md
- Generating keys: usage/generate-keys.md
- Deploy: usage/deploy.md
Expand Down
111 changes: 110 additions & 1 deletion docs/usage/generate-keys.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
We need 3 keys:
## Generate Keys

TODO blah we need a bunch of keys


<!-- We need 3 keys:

- VRF key
- KES key
Expand All @@ -19,4 +24,108 @@ spo-keys/
vrf.skey
kes.skey
opcert.cert
``` -->


### Variables

We set up a bunch of variables for the key generation. This depends on the network being used.

TODO where to get the values

```bash
# Pledge amount in Lovelace
export PLEDGE=1000000
# Pool cost per-epoch in Lovelace
export COST=170000000
# Pool cost per epoch in percentage
export MARGIN=0.1
# Preview network
export TESTNET_MAGIC=2
# Metadata
export METADATA_FILE=pool-metadata.json
echo '{
"name": "Test",
"description": "Test",
"ticker": "TEST",
"homepage": "https://example.com"
}' > $METADATA_FILE
export METADATA_HASH=`cardano-cli latest stake-pool metadata-hash --pool-metadata-file pool-metadata.json`

#
export RELAY_IPV4="87.227.245.188"
export RELAY_HOST="static.87.227.245.188.clients.your-server.de"
export RELAY_PORT=3000

export STAKE_DEPOSIT_AMOUNT=2000000
```

### Generate Keys


```bash
# Generate cold keys (not to be copied)
# cold.vkey, cold.skey and opcert.counter
cardano-cli latest node key-gen \
--cold-verification-key-file cold.vkey \
--cold-signing-key-file cold.skey \
--operational-certificate-issue-counter-file opcert.counter

# Generate payment keys
cardano-cli latest address key-gen \
--verification-key-file payment.vkey \
--signing-key-file payment.skey

# Generate stake keys
cardano-cli latest stake-address key-gen \
--verification-key-file stake.vkey \
--signing-key-file stake.skey

# Generate the payment address
cardano-cli latest address build \
--payment-verification-key-file payment.vkey \
--stake-verification-key-file stake.vkey \
--testnet-magic 2 \
--out-file payment.addr

# Generate KES keys
# kes.vkey, kes.skey
cardano-cli latest node key-gen-KES \
--verification-key-file kes.vkey \
--signing-key-file kes.skey

# Generate VRF keys
# vrf.vkey and vrf.skey
cardano-cli latest node key-gen-VRF \
--verification-key-file vrf.vkey \
--signing-key-file vrf.skey

cardano-cli latest stake-pool registration-certificate \
--cold-verification-key-file cold.vkey \
--vrf-verification-key-file vrf.vkey \
--pool-pledge $PLEDGE \
--pool-cost $COST \
--pool-margin $MARGIN \
--pool-reward-account-verification-key-file stake.vkey \
--pool-owner-stake-verification-key-file stake.vkey \
--testnet-magic $TESTNET_MAGIC \
--pool-relay-ipv4 $RELAY_IPV4 \
--pool-relay-port $RELAY_PORT \
--single-host-pool-relay $RELAY_HOST \
--metadata-url $METADATA_FILE \
--metadata-hash $METADATA_HASH \
--out-file pool-registration.cert

cardano-cli latest stake-address registration-certificate \
--key-reg-deposit-amt $STAKE_DEPOSIT_AMOUNT \
--stake-verification-key-file stake.vkey \
--out-file registration.cert

cardano-cli latest stake-address stake-delegation-certificate \
--stake-verification-key-file stake.vkey \
--cold-verification-key-file cold.vkey \
--out-file stake-delegation.cert

cardano-cli latest stake-pool id \
--output-format bech32 > pool_id.bech32
```
36 changes: 36 additions & 0 deletions docs/usage/setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Installation

Follow [this guide](https://zero-to-nix.com/start/install) to Install nix with [flakes](https://nix.dev/concepts/flakes.html) enabled.

### Binary cache

You can optionally use this project's binary cache to skip building software and download it instead. Edit `/etc/nix/nix.conf` (or related settings in NixOS config) and merge the new values separated by spaces into the options:

```
substituters = ... https://cache.staging.mlabs.city/spo-anywhere
trusted-public-keys = ... spo-anywhere:bmI58BmXnmeuAtMKbm3qhwiJ1RALMfo6cDwncfaGa6Q=
```

## Start new project from flake

Create a new directory, enter it, and initialize a new project form the spo-anywhere flake template.

```sh
mkdir my-spo
cd my-spo
nix flake init --template github:mlabs-haskell/spo-anywhere
```

Check that the installation script starts:

```sh
nix run .#install -- -h
```

## Cloud host

Prepare a cloud host and make sure you can reach it via ssh:

```sh
ssh
```
30 changes: 15 additions & 15 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 11 additions & 8 deletions modules/block-producer-node/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ in
};

configFilesPath = lib.mkOption {
type = lib.types.path;
description = "Path to the network configuration directory";
type = lib.types.nullOr lib.types.path;
default = null;
description = "Path to the network configuration directory. Optional, will use cardano-node service configuration if set to null.";
};
};
};
Expand All @@ -45,15 +46,17 @@ in
services.cardano-node = mkMerge [
{
enable = true;
}
(mkIf (cfg.configFilesPath != null) {
nodeConfigFile = "${cfg.configFilesPath}/configuration.yaml";
topology = "${cfg.configFilesPath}/topology-spo-1.json";
}
})
(mkIf (cfg.block-producer-key-path != null) {
signingKey = "${cfg.block-producer-key-path}/byron-gen-command/delegate-keys.000.key";
delegationCertificate = "${cfg.block-producer-key-path}/byron-gen-command/delegation-cert.000.json";
vrfKey = "${cfg.block-producer-key-path}/pools/vrf1.skey";
kesKey = "${cfg.block-producer-key-path}/pools/kes1.skey";
operationalCertificate = "${cfg.block-producer-key-path}/pools/opcert1.cert";
# signingKey = "${cfg.block-producer-key-path}/byron-gen-command/delegate-keys.000.key";
# delegationCertificate = "${cfg.block-producer-key-path}/byron-gen-command/delegation-cert.000.json";
vrfKey = "${cfg.block-producer-key-path}/vrf.skey";
kesKey = "${cfg.block-producer-key-path}/kes.skey";
operationalCertificate = "${cfg.block-producer-key-path}/opcert.cert";
})
];
};
Expand Down
6 changes: 3 additions & 3 deletions modules/install-script/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ inputs: {
with types; {
enable =
mkEnableOption "Create deployment script at `config.system.build.spoInstallScript`.";
target-dns = mkOption {
target = mkOption {
type = nullOr str;
default = null;
example = "[email protected]";
description = ''
The target DNS address to deploy to. Overwritten by a command line argument.
The target address to deploy to, in the format <user>@<host>, where host is a DNS hostname. Overwritten by a command line argument.
'';
};
};
Expand Down Expand Up @@ -46,7 +46,7 @@ inputs: {
rm -rf "$tmp_keys"
}

target="${builtins.toString (config.spo-anywhere.install-script.target-dns or "")}"
target="${builtins.toString (config.spo-anywhere.install-script.target or "")}"

# todo: make target optional option

Expand Down
57 changes: 0 additions & 57 deletions templates/basic/flake.nix

This file was deleted.

5 changes: 2 additions & 3 deletions templates/default.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{config, ...}: {
flake.templates = {
default = config.flake.templates.basic;
basic = {
path = ./basic;
default = {
path = ./default;
description = "Example flake using spo-anywhere";
};
};
Expand Down
Loading