forked from serokell/private-tezos-blockchain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactivate-protocol.sh
executable file
·121 lines (106 loc) · 3 KB
/
activate-protocol.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#! /usr/bin/env bash
# SPDX-FileCopyrightText: 2019 TQ Tezos <https://tqtezos.com/>
#
# SPDX-License-Identifier: MPL-2.0
set -euo pipefail
export TEZOS_CLIENT_UNSAFE_DISABLE_DISCLAIMER="Y"
activate_protocol() {
"$tezos_client" -A "$node_ip" -P "$node_port" -d "$client_dir" -l --block genesis activate protocol \
"$protocol" with fitness "$fitness" and key genesis and parameters "$parameters"
}
bake_block() {
"$tezos_client" -A "$node_ip" -P "$node_port" -d "$client_dir" -l bake for baker --minimal-timestamp
}
usage() {
echo "This script will activate a new protocol and bake the first block."
echo "OPTIONS:"
echo " --base-dir <filepath>. Base directory for storing tezos-client"
echo " data."
echo " --tezos-client <filepath>. Path for patched tezos-client executable"
echo " --parameters <filepath>. Path to JSON file with protocol parameters."
echo " [--node-ip | -A <int>]. Node rpc ip address, default is $node_ip."
echo " [--node-port | -P <int>]. Node rpc port, default is $node_port."
echo " [--fitness <int>]. Protocol activation fitness, default value is $fitness."
echo " [--base-chain <babylonnet | carthagenet>]. Define base chain for your private"
echo " blockchain. Default is 'carthagenet'."
}
fitness="25"
node_ip="localhost"
node_port="8732"
if [[ $# -eq 0 || $1 == "--help" ]]; then
usage
exit 1
fi
base_chain="carthagenet"
carthagenet_protocol="PsCARTHAGazKbHtnKfLzQg3kms52kSRpgnDY982a9oYsSXRLQEb"
while true; do
if [[ $# -eq 0 ]]; then
break
fi
case "$1" in
--base-dir | -d )
base_dir="$2"
shift 2
;;
--tezos-client)
tezos_client="$2"
shift 2
;;
--parameters)
parameters="$2"
shift 2
;;
--base-chain )
base_chain="$2"
shift 2
;;
--fitness)
fitness="$2"
shift 2
;;
--node-ip | -A)
node_ip="$2"
shift 2
;;
--node-port | -P)
node_port="$2"
shift 2
;;
*)
echo "Unexpected option \"$1\"."
usage
exit 1
;;
esac
done
exit_flag="false"
if [[ -z ${tezos_client:-} ]]; then
echo "\"--tezos-client\" wasn't provided."
exit_flag="true"
fi
if [[ -z ${base_dir:-} ]]; then
echo "\"--base-dir\" wasn't provided."
exit_flag="true"
fi
if [[ -z ${parameters:-} ]]; then
echo "\"--parameters\" wasn't provided."
exit_flag="true"
fi
[[ $exit_flag == "true" ]] && exit 1
case "$base_chain" in
babylonnet )
protocol="$babylonnet_protocol"
;;
carthagenet )
protocol="$carthagenet_protocol"
;;
*)
echo "$base_chain not supported. Only 'babylonnet' and 'carthagenet' are supported."
exit 1
;;
esac
mkdir -p "$base_dir"
client_dir="$base_dir/client"
mkdir -p "$client_dir"
activate_protocol
bake_block