@@ -49,8 +49,12 @@ run_migrations() {
49
49
50
50
# Function to start frost signer
51
51
start_frost_signer () {
52
+ local index=${SPARK_INDEX:- 0}
53
+ local signer_socket=" /tmp/frost_${index} .sock"
54
+
52
55
echo " Starting Frost signer..."
53
- spark-frost-signer -u /tmp/frost_0.sock &
56
+ echo " Signer socket: $signer_socket "
57
+ spark-frost-signer -u $signer_socket &
54
58
SIGNER_PID=$!
55
59
echo " Frost signer started with PID: $SIGNER_PID "
56
60
@@ -66,9 +70,10 @@ start_frost_signer() {
66
70
67
71
# Function to create identity key and operators config
68
72
create_identity_and_config () {
69
- local key_file=" /home/spark/operator_0.key"
73
+ local index=${SPARK_INDEX:- 0}
74
+ local key_file=" /home/spark/operator_${index} .key"
70
75
local operators_file=" /home/spark/operators.json"
71
- local keypair_file=" /home/spark/keypair .txt"
76
+ local keypair_file=" /home/spark/keypair_ ${index} .txt"
72
77
73
78
if [ ! -f " $keypair_file " ]; then
74
79
echo " Generating new secp256k1 key pair..."
@@ -110,15 +115,49 @@ create_identity_and_config() {
110
115
chmod 600 " $key_file "
111
116
112
117
echo " Creating operators configuration..."
113
- cat > " $operators_file " << EOF
118
+ if [ " $index " = " 0" ]; then
119
+ # Generate second operator's key for the JSON (using a different seed)
120
+ local public_key_2=$( python3 /usr/local/bin/keygen.py | grep " PUBLIC:" | cut -d: -f2)
121
+ cat > " $operators_file " << EOF
122
+ [
123
+ {
124
+ "id": 0,
125
+ "address": "0.0.0.0:10009",
126
+ "external_address": "spark:10009",
127
+ "address_dkg": "spark:10009",
128
+ "identity_public_key": "$public_key "
129
+ },
130
+ {
131
+ "id": 1,
132
+ "address": "0.0.0.0:10010",
133
+ "external_address": "spark2:10010",
134
+ "address_dkg": "spark2:10010",
135
+ "identity_public_key": "$public_key_2 "
136
+ }
137
+ ]
138
+ EOF
139
+ else
140
+ # For operator 1, create the same operators.json with both operators
141
+ # But we need to read operator 0's public key from shared config
142
+ cat > " $operators_file " << EOF
114
143
[
115
144
{
145
+ "id": 0,
116
146
"address": "0.0.0.0:10009",
117
147
"external_address": "spark:10009",
148
+ "address_dkg": "spark:10009",
149
+ "identity_public_key": "0322ca18fc489ae25418a0e768273c2c61cabb823edfb14feb891e9bec62016510"
150
+ },
151
+ {
152
+ "id": 1,
153
+ "address": "0.0.0.0:10010",
154
+ "external_address": "spark2:10010",
155
+ "address_dkg": "spark2:10010",
118
156
"identity_public_key": "$public_key "
119
157
}
120
158
]
121
159
EOF
160
+ fi
122
161
echo " Operators config created"
123
162
}
124
163
@@ -134,23 +173,31 @@ create_final_config() {
134
173
135
174
# Function to start spark operator
136
175
start_spark_operator () {
176
+ local index=${SPARK_INDEX:- 0}
177
+ local port=$(( 10009 + index))
178
+ local key_file=" /home/spark/operator_${index} .key"
179
+ local signer_socket=" unix:///tmp/frost_${index} .sock"
180
+
137
181
echo " Starting Spark operator..."
182
+ echo " Operator index: $index "
183
+ echo " Port: $port "
138
184
echo " Database URL being passed: '$DATABASE_URL '"
139
185
echo " Database URL starts with postgresql: $( echo " $DATABASE_URL " | grep -q " ^postgresql" && echo " YES" || echo " NO" ) "
140
186
echo " Config file database section:"
141
187
grep -A 10 " database:" /home/spark/so_config.yaml
142
188
143
189
echo " Starting with command:"
144
- echo " spark-operator -config /home/spark/so_config.yaml -index 0 -port 10009 -database '$DATABASE_URL ' -signer unix:///tmp/frost_0.sock -key /home/spark/operator_0.key -operators /home/spark/operators.json -supported-networks regtest -local -log-level debug"
190
+ echo " spark-operator -config /home/spark/so_config.yaml -index $index -port $port -database '$DATABASE_URL ' -signer $signer_socket -key $key_file -operators /home/spark/operators.json -threshold 2 -supported-networks regtest -local -log-level debug"
145
191
146
192
exec spark-operator \
147
193
-config /home/spark/so_config.yaml \
148
- -index 0 \
149
- -port 10009 \
194
+ -index $index \
195
+ -port $port \
150
196
-database " $DATABASE_URL " \
151
- -signer unix:///tmp/frost_0.sock \
152
- -key /home/spark/operator_0.key \
197
+ -signer $signer_socket \
198
+ -key $key_file \
153
199
-operators /home/spark/operators.json \
200
+ -threshold 2 \
154
201
-supported-networks regtest \
155
202
-local \
156
203
-log-level debug
0 commit comments