Skip to content

Commit 2f440f3

Browse files
aciceribrainrake
authored andcommitted
WIP
1 parent f310bb0 commit 2f440f3

File tree

10 files changed

+300
-0
lines changed

10 files changed

+300
-0
lines changed

templates/hetzner/1.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/env bash
2+
3+
set -ex
4+
5+
mkdir -p tmp
6+
pushd tmp
7+
rm -rf *
8+
9+
source vars.sh
10+
11+
# Generate cold keys (not to be copied)
12+
# cold.vkey, cold.skey and opcert.counter
13+
cardano-cli latest node key-gen \
14+
--cold-verification-key-file cold.vkey \
15+
--cold-signing-key-file cold.skey \
16+
--operational-certificate-issue-counter-file opcert.counter
17+
18+
# Generate payment keys
19+
cardano-cli latest address key-gen \
20+
--verification-key-file payment.vkey \
21+
--signing-key-file payment.skey
22+
23+
# Generate stake keys
24+
cardano-cli latest stake-address key-gen \
25+
--verification-key-file stake.vkey \
26+
--signing-key-file stake.skey
27+
28+
# Generate the payment address
29+
cardano-cli latest address build \
30+
--payment-verification-key-file payment.vkey \
31+
--stake-verification-key-file stake.vkey \
32+
--testnet-magic 2 \
33+
--out-file payment.addr
34+
35+
# Generate KES keys
36+
# kes.vkey, kes.skey
37+
cardano-cli latest node key-gen-KES \
38+
--verification-key-file kes.vkey \
39+
--signing-key-file kes.skey
40+
41+
# Generate VRF keys
42+
# vrf.vkey and vrf.skey
43+
cardano-cli latest node key-gen-VRF \
44+
--verification-key-file vrf.vkey \
45+
--signing-key-file vrf.skey
46+
47+
cardano-cli latest stake-pool registration-certificate \
48+
--cold-verification-key-file cold.vkey \
49+
--vrf-verification-key-file vrf.vkey \
50+
--pool-pledge $PLEDGE \
51+
--pool-cost $COST \
52+
--pool-margin $MARGIN \
53+
--pool-reward-account-verification-key-file stake.vkey \
54+
--pool-owner-stake-verification-key-file stake.vkey \
55+
--testnet-magic $TESTNET_MAGIC \
56+
--pool-relay-ipv4 $RELAY_IPV4 \
57+
--pool-relay-port $RELAY_PORT \
58+
--single-host-pool-relay $RELAY_HOST \
59+
--metadata-url $METADATA_FILE \
60+
--metadata-hash $METADATA_HASH \
61+
--out-file pool-registration.cert
62+
63+
cardano-cli latest stake-address registration-certificate \
64+
--key-reg-deposit-amt $STAKE_DEPOSIT_AMOUNT \
65+
--stake-verification-key-file stake.vkey \
66+
--out-file registration.cert
67+
68+
cardano-cli latest stake-address stake-delegation-certificate \
69+
--stake-verification-key-file stake.vkey \
70+
--cold-verification-key-file cold.vkey \
71+
--out-file stake-delegation.cert
72+
73+
cardano-cli latest stake-pool id \
74+
75+
--output-format bech32 > pool_id.bech32
76+
77+
popd

templates/hetzner/2.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env bash
2+
3+
set -xe
4+
5+
TESTNET_MAGIC=${TESTNET_MAGIC:-2}
6+
7+
cardano-cli latest transaction build \
8+
--testnet-magic $TESTNET_MAGIC \
9+
--witness-override 2 \
10+
--tx-in $(cardano-cli query utxo --address $(cat payment.addr) --testnet-magic $TESTNET_MAGIC --out-file /dev/stdout | jq -r 'keys[0]') \
11+
--change-address $(cat payment.addr) \
12+
--certificate-file registration.cert \
13+
--out-file tx.raw
14+
15+
cardano-cli latest transaction sign \
16+
--tx-body-file tx.raw \
17+
--signing-key-file payment.skey \
18+
--signing-key-file stake.skey \
19+
--testnet-magic $TESTNET_MAGIC \
20+
--out-file tx.signed
21+
22+
cardano-cli latest transaction submit \
23+
--testnet-magic 2 \
24+
--tx-file tx.signed
25+
26+
# Wait a bit?
27+
28+
cardano-cli latest transaction build \
29+
--testnet-magic $TESTNET_MAGIC \
30+
--witness-override 3 \
31+
--tx-in $(cardano-cli query utxo --address $(cat payment.addr) --testnet-magic $TESTNET_MAGIC --out-file /dev/stdout | jq -r 'keys[0]') \
32+
--change-address $(cat payment.addr) \
33+
--certificate-file pool-registration.cert \
34+
--certificate-file stake-delegation.cert \
35+
--out-file tx.raw
36+
37+
cardano-cli latest transaction sign \
38+
--tx-body-file tx.raw \
39+
--signing-key-file payment.skey \
40+
--signing-key-file cold.skey \
41+
--signing-key-file stake.skey \
42+
--testnet-magic 2 \
43+
--out-file tx.signed
44+
45+
cardano-cli latest transaction submit \
46+
--testnet-magic $TESTNET_MAGIC \
47+
--tx-file tx.signed

templates/hetzner/3.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
set -xe
4+
5+
source vars.sh
6+
7+
cardano-cli node issue-op-cert --kes-verification-key-file tmp/kes.vkey \
8+
--cold-signing-key-file tmp/cold.skey \
9+
--operational-certificate-issue-counter-file tmp/opcert.counter \
10+
--kes-period $1 \
11+
--out-file tmp/opcert.cert

templates/hetzner/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# SPO-Anywhere on Hetzner Cloud
2+
3+
This Nix flake template installs a Stake Pool on Hetzner cloud using `spo-anywhere`.
4+
5+
## Prerequisites
6+
7+
To get started create an Hetzner cloud machine (tested with Ubuntu) and make sure you are able to connect as `root` with ssh.
8+
9+
You also need to generate a set of stake pool keys, you can follow our documentation section on [generating keys](https://mlabs-haskell.github.io/spo-anywhere/usage/generate-keys/).
10+
11+
https://mithril.network/explorer/?aggregator=https%3A%2F%2Faggregator.pre-release-preview.api.mithril.network%2Faggregator
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
networking.hostName = "spo-node-hetzner";
3+
4+
system.stateVersion = "24.11";
5+
6+
users.users.root.openssh.authorizedKeys.keys = [
7+
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCzCmDCtlGscpesHuoiruVWD2IjYEFtaIl9Y2JZGiOAyf3V17KPx0MikcknfmxSHi399SxppiaXQHxo/1wjGxXkXNTTv6h1fBuqwhJE6C8+ZSV+gal81vEnXX+/9w2FQqtVgnG2/mO7oJ0e3FY+6kFpOsGEhYexoGt/UxIpAZoqIN+CWNhJIASUkneaZWtgwiL8Afb59kJQ2E7WbBu+PjYZ/s5lhPobhlkz6s8rkhItvYdiSHT0DPDKvp1oEbxsxd4E4cjJFbahyS8b089NJd9gF5gs0b74H/2lUUymnl63cV37Mp4iXB4rtE69MbjqsGEBKTPumLualmc8pOGBHqWIdhAqGdZQeBajcb6VK0E3hcU0wBB+GJgm7KUzlAHGdC3azY0KlHMrLaZN0pBrgCVR6zBNWtZz2B2qMBZ8Cw+K4vut8GuspdXZscID10U578GxQvJAB9CdxNUtrzSmKX2UtZPB1udWjjIAlejzba4MG73uXgQEdv0NcuHNwaLuCWxTUT5QQF18IwlJ23Mg8aPK8ojUW5A+kGHAu9wtgZVcX1nS5cmYKSgLzcP1LA1l9fTJ1vqBSuy38GTdUzfzz7AbnkRfGPj2ALDgyx17Rc5ommjc1k0gFoeIqiLaxEs5FzDcRyo7YvZXPsGeIqNCYwQWw3+U+yUEJby8bxGb2d/6YQ=="
8+
];
9+
10+
spo-anywhere = {
11+
node = {
12+
enable = true;
13+
block-producer-key-path = "/var/lib/spo";
14+
};
15+
install-script = {
16+
enable = true;
17+
target = "root@188.245.227.87";
18+
};
19+
};
20+
21+
services.cardano-node = {
22+
environment = "preview";
23+
};
24+
}

templates/hetzner/disko.nix

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
inputs = {
3+
# spo-anywhere.url = "github:mlabs-haskell/spo-anywhere/aciceri/hetzner-template"; # TODO go back to `main` once merged
4+
spo-anywhere.url = "../..";
5+
srvos.url = "github:nix-community/srvos";
6+
nixpkgs.follows = "srvos/nixpkgs";
7+
disko.follows = "spo-anywhere/disko";
8+
};
9+
outputs = inputs @ {
10+
nixpkgs,
11+
flake-parts,
12+
spo-anywhere,
13+
srvos,
14+
disko,
15+
...
16+
}:
17+
flake-parts.lib.mkFlake {
18+
inherit inputs;
19+
} ({config, ...}: {
20+
systems = [
21+
"x86_64-linux"
22+
];
23+
flake.nixosConfigurations.spo-node-hetzner = nixpkgs.lib.nixosSystem {
24+
system = "x86_64-linux";
25+
modules = [
26+
spo-anywhere.nixosModules.default
27+
srvos.nixosModules.server
28+
srvos.nixosModules.hardware-hetzner-cloud
29+
disko.nixosModules.disko
30+
./configuration.nix
31+
./disko.nix
32+
];
33+
};
34+
perSystem = {...}: {
35+
packages = {
36+
install = config.flake.nixosConfigurations.spo-node-hetzner.config.system.build.spoInstallScript;
37+
};
38+
};
39+
});
40+
}

templates/hetzner/flake.nix

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
inputs = {
3+
# spo-anywhere.url = "github:mlabs-haskell/spo-anywhere/aciceri/hetzner-template"; # TODO go back to `main` once merged
4+
spo-anywhere.url = "../..";
5+
srvos.url = "github:nix-community/srvos";
6+
nixpkgs.follows = "srvos/nixpkgs";
7+
disko.follows = "spo-anywhere/disko";
8+
};
9+
outputs = inputs @ {
10+
nixpkgs,
11+
flake-parts,
12+
spo-anywhere,
13+
srvos,
14+
disko,
15+
...
16+
}:
17+
flake-parts.lib.mkFlake {
18+
inherit inputs;
19+
} ({config, ...}: {
20+
systems = [
21+
"x86_64-linux"
22+
];
23+
flake.nixosConfigurations.spo-node-hetzner = nixpkgs.lib.nixosSystem {
24+
system = "x86_64-linux";
25+
modules = [
26+
spo-anywhere.nixosModules.default
27+
srvos.nixosModules.server
28+
srvos.nixosModules.hardware-hetzner-cloud
29+
disko.nixosModules.disko
30+
./configuration.nix
31+
./disko.nix
32+
];
33+
};
34+
perSystem = {...}: {
35+
packages = {
36+
install = config.flake.nixosConfigurations.spo-node-hetzner.config.system.build.spoInstallScript;
37+
};
38+
};
39+
});
40+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "Test",
3+
"description": "Test",
4+
"ticker": "TEST",
5+
"homepage": "https://mlabs-haskell.github.io/spo-anywhere"
6+
}

templates/hetzner/topology.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"localRoots":[
3+
{
4+
"accessPoints":[
5+
{
6+
"address":"preview-node.world.dev.cardano.org",
7+
"port":30002
8+
}
9+
],
10+
"advertise":false,
11+
"valency":1
12+
}
13+
],
14+
"publicRoots":[
15+
{
16+
"accessPoints":[
17+
18+
],
19+
"advertise":false
20+
}
21+
],
22+
"useLedgerAfterSlot":-1
23+
}

templates/hetzner/vars.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Pledge amount in Lovelace
2+
PLEDGE=1000000
3+
# Pool cost per-epoch in Lovelace
4+
COST=170000000
5+
# Pool cost per epoch in percentage
6+
MARGIN=0.1
7+
# Preview network
8+
TESTNET_MAGIC=2
9+
# Metadata
10+
METADATA_FILE=pool-metadata.json
11+
echo '{
12+
"name": "Test",
13+
"description": "Test",
14+
"ticker": "TEST",
15+
"homepage": "https://mlabs-haskell.github.io/spo-anywhere"
16+
}' > $METADATA_FILE
17+
METADATA_HASH=`cardano-cli latest stake-pool metadata-hash --pool-metadata-file pool-metadata.json`
18+
RELAY_IPV4="87.227.245.188"
19+
RELAY_HOST="static.87.227.245.188.clients.your-server.de"
20+
RELAY_PORT=3000
21+
STAKE_DEPOSIT_AMOUNT=2000000

0 commit comments

Comments
 (0)