Skip to content

Commit a25d4a3

Browse files
authored
Merge pull request #710 from hyperweb-io/anmol/cosmos-refactor
feature: initial refactor for cosmos chains to various componenets
2 parents 7bffb00 + d997813 commit a25d4a3

File tree

67 files changed

+9038
-2277
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+9038
-2277
lines changed

packages/packages/generator/__tests__/__output__/builder-tests/build-chain/persistencecore/genesis-statefulset.yaml

Lines changed: 118 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,47 @@ spec:
122122
command:
123123
- bash
124124
- '-c'
125-
- /scripts/create-genesis.sh
125+
- >-
126+
VAL_INDEX=${HOSTNAME##*-}
127+
128+
echo "Validator Index: $VAL_INDEX"
129+
130+
131+
cp $CHAIN_DIR/cosmovisor/genesis/bin/$CHAIN_BIN /usr/bin
132+
133+
134+
if [ -f $CHAIN_DIR/config/genesis.json ]; then
135+
echo "Genesis file exists, exiting init container"
136+
exit 0
137+
fi
138+
139+
140+
echo "Running setup genesis script..."
141+
142+
bash -e /scripts/create-genesis.sh
143+
144+
bash -e /scripts/update-genesis.sh
145+
146+
147+
echo "Create node id json file"
148+
149+
NODE_ID=$($CHAIN_BIN tendermint show-node-id)
150+
151+
echo '{"node_id":"'$NODE_ID'"}' > $CHAIN_DIR/config/node_id.json
152+
153+
154+
echo "Create consensus key json file"
155+
156+
$CHAIN_BIN tendermint show-validator >
157+
$CHAIN_DIR/config/consensus_key.json
158+
159+
cat $CHAIN_DIR/config/consensus_key.json
160+
161+
162+
echo "Add custom accounts and balances"
163+
164+
CHAIN_GENESIS_CMD=$($CHAIN_BIN 2>&1 | grep -q "genesis-related
165+
subcommands" && echo "genesis" || echo "")
126166
resources:
127167
limits:
128168
cpu: '2'
@@ -164,7 +204,15 @@ spec:
164204
command:
165205
- bash
166206
- '-c'
167-
- /scripts/update-config.sh
207+
- |-
208+
VAL_INDEX=${HOSTNAME##*-}
209+
echo "Validator Index: $VAL_INDEX"
210+
211+
cp $CHAIN_DIR/cosmovisor/genesis/bin/$CHAIN_BIN /usr/bin
212+
213+
echo "Running setup config script..."
214+
215+
bash -e /scripts/update-config.sh
168216
resources:
169217
limits:
170218
cpu: '2'
@@ -221,19 +269,21 @@ spec:
221269
value: 'true'
222270
- name: SLOGFILE
223271
value: slog.slog
272+
- name: DAEMON_NAME
273+
value: persistenceCore
274+
- name: DAEMON_HOME
275+
value: /root/.persistenceCore
224276
command:
225277
- bash
226278
- '-c'
227-
- >-
279+
- |-
228280
#!/bin/bash
229-
230281
set -euo pipefail
231282
283+
START_ARGS=""
232284
233-
echo "Starting persistenceCore validator..."
234285
235-
exec persistenceCore start --home /root/.persistenceCore
236-
--log_level info
286+
/usr/bin/cosmovisor start $START_ARGS
237287
resources:
238288
limits:
239289
cpu: '2'
@@ -301,31 +351,66 @@ spec:
301351
- mountPath: /configs
302352
name: addresses
303353
- name: faucet
304-
image: busybox:1.34.1
354+
image: ghcr.io/cosmology-tech/starship/runner:latest
305355
imagePullPolicy: IfNotPresent
306356
env:
307357
- name: FAUCET_CONCURRENCY
308358
value: '5'
309-
- name: FAUCET_PORT
359+
- name: FAUCET_HTTP_PORT
310360
value: '8000'
361+
- name: FAUCET_CHAIN_BINARY
362+
value: persistenceCore
311363
- name: FAUCET_CHAIN_ID
312364
value: core-1
313-
- name: FAUCET_CHAIN_DENOM
314-
value: uxprt
315-
- name: FAUCET_CHAIN_PREFIX
316-
value: persistence
317-
- name: FAUCET_AMOUNT_SEND
318-
value: '10000000'
319-
- name: FAUCET_AMOUNT_STAKE
320-
value: '10000000'
321-
- name: FAUCET_RPC_ENDPOINT
322-
value: http://localhost:26657
323-
- name: FAUCET_REST_ENDPOINT
324-
value: http://localhost:1317
365+
- name: COINS
366+
value: 100000000000000uxprt
325367
command:
326-
- sh
368+
- bash
327369
- '-c'
328-
- /faucet/faucet
370+
- >-
371+
CREDIT_COINS=""
372+
373+
FEES=""
374+
375+
for coin in ${COINS//,/ }
376+
377+
do
378+
amt="${coin//[!0-9]/}"
379+
denom="${coin//[0-9]/}"
380+
381+
# Calculate the order of magnitude
382+
if [ ${#amt} -gt 18 ]; then
383+
creditAmt=$(echo $amt | sed -e "s/000000$//")
384+
feesAmt=$(echo $amt | sed -e "s/0000000000000$//")
385+
else
386+
creditAmt=$(echo $amt | sed -e "s/0000$//")
387+
feesAmt=$(echo $amt | sed -e "s/00000000$//")
388+
fi
389+
390+
if [[ $CREDIT_COINS == "" ]]
391+
then
392+
CREDIT_COINS="$creditAmt$denom"
393+
FEES="$feesAmt$denom"
394+
else
395+
CREDIT_COINS="${CREDIT_COINS},$creditAmt$denom"
396+
fi
397+
done
398+
399+
400+
export FAUCET_MNEMONIC=$(jq -r ".faucet[0].mnemonic"
401+
/configs/keys.json)
402+
403+
404+
export | grep "FAUCET"
405+
406+
407+
until bash -e /scripts/chain-rpc-ready.sh http://localhost:26657;
408+
do
409+
sleep 10
410+
done
411+
412+
413+
/faucet/faucet --credit-coins="$CREDIT_COINS" --chain-fees="$FEES"
329414
resources:
330415
limits:
331416
cpu: '0.1'
@@ -338,6 +423,14 @@ spec:
338423
name: addresses
339424
- mountPath: /faucet
340425
name: faucet
426+
- mountPath: /scripts
427+
name: scripts
428+
readinessProbe:
429+
httpGet:
430+
path: /status
431+
port: '8000'
432+
initialDelaySeconds: 30
433+
periodSeconds: 10
341434
volumes:
342435
- name: node
343436
emptyDir: {}
@@ -347,3 +440,5 @@ spec:
347440
- name: scripts
348441
configMap:
349442
name: setup-scripts-core-1
443+
- name: faucet
444+
emptyDir: {}

packages/packages/generator/__tests__/__output__/builder-tests/build-chain/persistencecore/setup-scripts-configmap.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ metadata:
1010
app.kubernetes.io/name: persistencecore
1111
app.kubernetes.io/part-of: core-1
1212
app.kubernetes.io/role: setup-scripts
13+
starship.io/chain-name: persistencecore
14+
starship.io/chain-id: core-1
1315
data:
1416
create-genesis.sh: >
1517
#!/bin/bash

0 commit comments

Comments
 (0)