-
Notifications
You must be signed in to change notification settings - Fork 1
/
update-genesis-start-time.sh
executable file
·75 lines (48 loc) · 2.49 KB
/
update-genesis-start-time.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env bash
set -euo pipefail
# Remove previously generated keys and files and db files
rm -rf $CNODE_HOME/db/*
rm -rf $CNODE_HOME/sockets/*
rm -rf $CNODE_HOME/files/*
# Create the genesis files and configs for the network, and the various keys that the nodes use.
[ -z ${NETWORK_MAGIC+x} ]&& ( echo "Environment variable NETWORK_MAGIC must be defined"; exit 1)
DELAY="${DELAY:-30}"
if [[ "$OSTYPE" == "darwin"* ]]; then
SYSTEM_START=`date -u -v +${DELAY}M +'%Y-%m-%dT%H:%M:%SZ'`
UNIX_EPOCH_TIME=`date -u -j -f "%FT%TZ" "$SYSTEM_START" +\%s`
else
SYSTEM_START=`date -u -d "today + $DELAY minutes" +'%Y-%m-%dT%H:%M:%SZ'`
UNIX_EPOCH_TIME=`date +\%s -d "$SYSTEM_START"`
fi
echo "Updating genesis using following environments variables:
NETWORK_MAGIC: $NETWORK_MAGIC
DELAY: $DELAY (delay in minutes before genesis systemStart)
systemStart: $SYSTEM_START
"
EPOCH_LENGTH=`perl -E "say ((10 * $K) / $F)"`
EPOCH_LENGTH_MINUTES=`perl -E "say (($EPOCH_LENGTH / 60) * $SLOT_LENGTH )"`
EPOCH_LENGTH_MINUTES_INT=${EPOCH_LENGTH_MINUTES%.*}
RETURN_ADDRESS=$(cat keys/utxo-keys/utxo1_stk.addr)
# Create keys file
mkdir -p $CNODE_HOME/generated-keys/
mkdir -p $CNODE_HOME/initial-keys/
mkdir -p $CNODE_HOME/priv/pool/$POOL_NAME
# copy the config files
sed -i "s/\"startTime\": [0-9]*/\"startTime\": $UNIX_EPOCH_TIME/" "templates/genesis-byron.json" && \
sed -i "s/\"systemStart\": \".*\"/\"systemStart\": \"$SYSTEM_START\"/" "templates/genesis-shelley.json"
sed -i "s/\"protocolMagic\": [0-9]*/\"protocolMagic\": $NETWORK_MAGIC/" "templates/genesis-byron.json"
sed -i "s/\"networkMagic\": [0-9]*/\"networkMagic\": $NETWORK_MAGIC/" "templates/genesis-shelley.json"
cp templates/genesis-byron.json $CNODE_HOME/files/byron-genesis.json
cp templates/genesis-shelley.json $CNODE_HOME/files/shelley-genesis.json
cp templates/genesis-alonzo.json $CNODE_HOME/files/alonzo-genesis.json
cp templates/conway-genesis.json $CNODE_HOME/files/conway-genesis.json
cp templates/cardano-node.json $CNODE_HOME/files/config.json
cp templates/dbsync.json $CNODE_HOME/files/dbsync.json
cp templates/topology.json $CNODE_HOME/files/topology.json
#copy the keys
cp keys/node-keys/kes.skey $CNODE_HOME/priv/pool/$POOL_NAME/hot.skey
cp keys/node-keys/vrf.skey $CNODE_HOME/priv/pool/$POOL_NAME/vrf.skey
cp keys/node-keys/opcert.cert $CNODE_HOME/priv/pool/$POOL_NAME/op.cert
sudo chmod o-rwx $CNODE_HOME/priv/pool/$POOL_NAME/vrf.skey
sudo chmod g-rwx $CNODE_HOME/priv/pool/$POOL_NAME/vrf.skey
cp -r keys/utxo-keys/* $CNODE_HOME/initial-keys