Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial version - celestia app charts #84

Merged
merged 13 commits into from
Dec 11, 2024
7 changes: 5 additions & 2 deletions charts/celestia-app/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ annotations:
category: celestia
licenses: Apache-2.0
apiVersion: v2
appVersion: v2.2.0
appVersion: v3.0.0
dependencies:
- name: common-celestia-app
version: 0.1.1
tty47 marked this conversation as resolved.
Show resolved Hide resolved
repository: https://celestiaorg.github.io/helm-charts
- name: common
repository: oci://registry-1.docker.io/bitnamicharts
tags:
Expand All @@ -21,4 +24,4 @@ maintainers:
name: celestia-app
sources:
- https://github.com/celestiaorg/celestia-app
version: 0.3.1
version: 0.3.2
2 changes: 1 addition & 1 deletion charts/celestia-app/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# celestia-app

![Version: 0.3.1](https://img.shields.io/badge/Version-0.3.1-informational?style=flat-square) ![AppVersion: v2.2.0](https://img.shields.io/badge/AppVersion-v2.2.0-informational?style=flat-square)
![Version: 0.3.2](https://img.shields.io/badge/Version-0.3.2-informational?style=flat-square) ![AppVersion: v3.0.0](https://img.shields.io/badge/AppVersion-v3.0.0-informational?style=flat-square)
tty47 marked this conversation as resolved.
Show resolved Hide resolved

Celestia App

Expand Down
1 change: 1 addition & 0 deletions charts/celestia-app/charts/common-celestia-app
40 changes: 40 additions & 0 deletions charts/celestia-app/files/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/sh
# CELESTIA_HOME should be set in the environment
# APP_ID should be set in the environment
# CHAIN_ID should be set in the environment
# INITIAL_TIA_AMOUNT should be set in the environment
# STAKING_TIA_AMOUNT should be set in the environment
# EVM_ADDRESS should be set in the environment

KEY_NAME="${APP_ID}-${CHAIN_ID}"

echo "---------------------------------------------------"
echo "Checking if the file [genesis.json] exists or not..."
echo "---------------------------------------------------"
if [[ ! -f "$CELESTIA_HOME/config/genesis.json" ]]; then
celestia-appd init "${APP_ID}" --home "${CELESTIA_HOME}" --chain-id "${CHAIN_ID}"

# yes n | celestia-appd keys add "${KEY_NAME}" --home "${CELESTIA_HOME}" --no-backup
celestia-appd keys add "${KEY_NAME}" --home "${CELESTIA_HOME}" --no-backup

account_address=$(celestia-appd keys show "${KEY_NAME}" -a --home "${CELESTIA_HOME}")
celestia-appd add-genesis-account "${account_address}" "${INITIAL_TIA_AMOUNT}" --home "${CELESTIA_HOME}"

celestia-appd gentx "${KEY_NAME}" "${STAKING_TIA_AMOUNT}" --home "${CELESTIA_HOME}" --chain-id "${CHAIN_ID}"

celestia-appd collect-gentxs --home "${CELESTIA_HOME}"

echo "Copying the keys to the config path..."
mv $CELESTIA_HOME/config/priv_validator_key.json $CELESTIA_HOME/keys
mv $CELESTIA_HOME/config/node_key.json $CELESTIA_HOME/keys
fi

echo "Configuration applied [$CELESTIA_HOME/config/config.toml]"
echo "---------------------------------------------------"
cat $CELESTIA_HOME/config/config.toml
echo "Configuration applied [$CELESTIA_HOME/config/app.toml]"
echo "---------------------------------------------------"
cat $CELESTIA_HOME/config/app.toml
echo "Configuration applied [$CELESTIA_HOME/config/client.toml]"
echo "---------------------------------------------------"
cat $CELESTIA_HOME/config/client.toml
122 changes: 122 additions & 0 deletions charts/celestia-app/files/val-maker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#!/bin/sh

set -e

# CELESTIA_HOME should be set in the environment
# CHAIN_ID should be set in the environment
# FUND_TIA_AMOUNT should be set in the environment
# STAKING_TIA_AMOUNT should be set in the environment

# CONSENSUS_VALIDATOR_POD should be set in the environment
# CONSENSUS_VALIDATOR_NAMEPACE should be set in the environment

# CONENSUS_VALIDATOR_POD_NOMINATEES should be set in the environment

CONSENSUS_VALIDATOR_KEY_NAME="${CONSENSUS_VALIDATOR_POD}-${CHAIN_ID}"

# wait until validator is ready and all containers are ready
echo "---------------------------------------------------"
echo "Waiting for ${CONSENSUS_VALIDATOR_POD} to be ready..."
echo "---------------------------------------------------"
kubectl wait --for=condition=Ready pod/${CONSENSUS_VALIDATOR_POD} -n "${CONSENSUS_VALIDATOR_NAMESPACE}" --timeout=300s

for CONENSUS_VALIDATOR_POD_NOMINATEE in $(echo $CONENSUS_VALIDATOR_POD_NOMINATEES | sed "s/,/ /g")
do

# wait until validator is ready and all containers are ready
echo "---------------------------------------------------"
echo "Waiting for ${CONENSUS_VALIDATOR_POD_NOMINATEE} to be ready..."
echo "---------------------------------------------------"
until kubectl wait --for=condition=Ready pod/${CONENSUS_VALIDATOR_POD_NOMINATEE} -n "${CONSENSUS_VALIDATOR_NAMESPACE}" --timeout=300s; do
echo "Command timed out, retrying..."
sleep 5
done

# fetch account address from nominatee
echo "---------------------------------------------------"
echo "Fetching account address from ${CONENSUS_VALIDATOR_POD_NOMINATEE}"
echo "---------------------------------------------------"
fetch_address_command="celestia-appd keys show ${CONENSUS_VALIDATOR_POD_NOMINATEE}-${CHAIN_ID} -a --home ${CELESTIA_HOME}"

echo $fetch_address_command
nominatee_address=$(kubectl -n ${CONSENSUS_VALIDATOR_NAMESPACE} exec -t ${CONENSUS_VALIDATOR_POD_NOMINATEE} --container=consensus -- /bin/sh -c "${fetch_address_command}")
echo "nominatee_address: ${nominatee_address}"

# fetch validator address from nominatee
echo "---------------------------------------------------"
echo "Fetching validator address from ${CONENSUS_VALIDATOR_POD_NOMINATEE}"
echo "---------------------------------------------------"
fetch_validator_address_command="celestia-appd keys show ${CONENSUS_VALIDATOR_POD_NOMINATEE}-${CHAIN_ID} -a --bech val --home ${CELESTIA_HOME}"

echo $fetch_validator_address_command
validator_address=$(kubectl -n ${CONSENSUS_VALIDATOR_NAMESPACE} exec -t ${CONENSUS_VALIDATOR_POD_NOMINATEE} --container=consensus -- /bin/sh -c "${fetch_validator_address_command}")
echo "validator_address: ${validator_address}"

# fetch validator pubkey from nominatee
echo "---------------------------------------------------"
echo "Fetching validator pubkey from ${CONENSUS_VALIDATOR_POD_NOMINATEE}"
echo "---------------------------------------------------"
fetch_pubkey_command="celestia-appd tendermint show-validator --home ${CELESTIA_HOME}"

echo $fetch_pubkey_command
nominatee_pubkey=$(kubectl -n ${CONSENSUS_VALIDATOR_NAMESPACE} exec -t ${CONENSUS_VALIDATOR_POD_NOMINATEE} --container=consensus -- /bin/sh -c "${fetch_pubkey_command}")
echo "nominatee_pubkey: ${nominatee_pubkey}"

# check if nominatee is already a validator
echo "---------------------------------------------------"
echo "Checking if ${CONENSUS_VALIDATOR_POD_NOMINATEE} is already a validator"
echo "---------------------------------------------------"
status_command="celestia-appd query staking validator ${validator_address} --chain-id ${CHAIN_ID} --home ${CELESTIA_HOME}"

echo $status_command
if kubectl -n ${CONSENSUS_VALIDATOR_NAMESPACE} exec -t ${CONENSUS_VALIDATOR_POD_NOMINATEE} --container=consensus -- /bin/sh -c "${status_command}" > /dev/null 2>&1; then
echo "${CONENSUS_VALIDATOR_POD_NOMINATEE} is already a validator, skipping..."
continue
fi

# fund nominatee from validator
echo "---------------------------------------------------"
echo "Funding ${CONENSUS_VALIDATOR_POD_NOMINATEE} from ${CONSENSUS_VALIDATOR_POD}"
echo "---------------------------------------------------"
send_command="celestia-appd tx bank send \
${CONSENSUS_VALIDATOR_KEY_NAME} \
${nominatee_address} \
${FUND_TIA_AMOUNT} \
--chain-id ${CHAIN_ID} \
--fees 22000utia \
--home ${CELESTIA_HOME} \
--yes"

echo $send_command
kubectl -n ${CONSENSUS_VALIDATOR_NAMESPACE} exec -t ${CONSENSUS_VALIDATOR_POD} --container=consensus -- /bin/sh -c "${send_command}"

sleep 15

# make nominatee a validator
echo "---------------------------------------------------"
echo "Making ${CONENSUS_VALIDATOR_POD_NOMINATEE} a validator"
echo "---------------------------------------------------"
stake_command="celestia-appd tx staking create-validator \
--amount ${STAKING_TIA_AMOUNT} \
--pubkey '${nominatee_pubkey}' \
--moniker ${CONENSUS_VALIDATOR_POD_NOMINATEE}-${CHAIN_ID} \
--chain-id ${CHAIN_ID} \
--commission-rate 0.1 \
--commission-max-rate 0.2 \
--commission-max-change-rate 0.01 \
--min-self-delegation 1000000 \
--from ${CONENSUS_VALIDATOR_POD_NOMINATEE}-${CHAIN_ID} \
--keyring-backend test \
--fees 21000utia \
--home ${CELESTIA_HOME} \
--yes"

echo $stake_command
kubectl -n ${CONSENSUS_VALIDATOR_NAMESPACE} exec -t ${CONENSUS_VALIDATOR_POD_NOMINATEE} --container=consensus -- /bin/sh -c "${stake_command}"
done

# I'm done and wait forever
echo "---------------------------------------------------"
echo "I'm done and wait forever"
echo "---------------------------------------------------"
sleep infinity
6 changes: 4 additions & 2 deletions charts/celestia-app/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if .Values.app.rbac.create }}
kind: ClusterRoleBinding
apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }}
metadata:
Expand All @@ -10,8 +11,9 @@ metadata:
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ template "common.names.fullname" . }}
name: {{ include "common.names.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ template "app.serviceAccountName" . }}
name: {{ .Values.app.serviceAccount.name }}
namespace: {{ include "common.names.namespace" . | quote }}
{{- end }}
Loading
Loading