Skip to content

Commit

Permalink
feat(charts): hermes chart (#950)
Browse files Browse the repository at this point in the history
## Summary
Adds a hermes relayer chart which can be utilized to connect two IBC
compatible chains for relaying.

Note: I have not been able to get the local connection working yet but
have confirmed against celestia mocha.
  • Loading branch information
joroshiba authored Apr 18, 2024
1 parent 4357edd commit 6d25f2c
Show file tree
Hide file tree
Showing 21 changed files with 803 additions and 14 deletions.
6 changes: 3 additions & 3 deletions charts/celestia-local/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: celestia-local
description: A Helm chart for Kubernetes
description: Helm chart to deploy a local celestia network, for testing purposes

# A chart can be either an 'application' or a 'library' chart.
#
Expand All @@ -15,13 +15,13 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.3.6
version: 0.3.7

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.3.0"
appVersion: "1.6.0"

maintainers:
- name: wafflesvonmaple
Expand Down
15 changes: 11 additions & 4 deletions charts/celestia-local/files/scripts/init-celestia-appd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

set -o errexit -o nounset

# if app config already exists then we have already ran initialization.
if [ -f "$home_dir/config/config.toml" ]; then
exit 0
fi
Expand All @@ -11,10 +10,11 @@ celestia-appd init "$chainid" \
--chain-id "$chainid" \
--home "$home_dir"

celestia-appd keys add \
echo "$validator_mnemonic" | celestia-appd keys add \
"$validator_key_name" \
--home "$home_dir" \
--keyring-backend="$keyring_backend" \
--home "$home_dir"
--recover

validator_key=$(celestia-appd keys show "$validator_key_name" -a --keyring-backend="$keyring_backend" --home "$home_dir")
celestia-appd add-genesis-account \
Expand All @@ -27,6 +27,13 @@ celestia-appd gentx \
"$validator_stake" \
--keyring-backend="$keyring_backend" \
--chain-id "$chainid" \
--home "$home_dir" \
--home "$home_dir"

celestia-appd collect-gentxs --home "$home_dir"

# Enable transaction indexing
sed -i'.bak' 's#"null"#"kv"#g' "${home_dir}"/config/config.toml
# Persist ABCI responses
sed -i'.bak' 's#discard_abci_responses = true#discard_abci_responses = false#g' "${home_dir}"/config/config.toml
# Override the VotingPeriod from 1 week to 1 minute
sed -i'.bak' 's#"604800s"#"60s"#g' "${home_dir}"/config/genesis.json
2 changes: 1 addition & 1 deletion charts/celestia-local/files/scripts/start-bridge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ echo "waiting for genesis hash from celestia..."
genesis_hash=$(wait_for_genesis)
echo "genesis hash received: $genesis_hash"

export CELESTIA_CUSTOM="test:$genesis_hash"
export CELESTIA_CUSTOM="$chainid:$genesis_hash"
export GOLOG_LOG_LEVEL="debug"

# fixes: keystore: permissions of key 'p2p-key' are too relaxed: required: 0600, got: 0660
Expand Down
3 changes: 2 additions & 1 deletion charts/celestia-local/files/scripts/start-celestia-appd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ set -o errexit -o nounset
} &

exec celestia-appd start --home "${home_dir}" \
--grpc.address "127.0.0.1:$celestia_app_grpc_port" \
--grpc.address "0.0.0.0:$celestia_app_grpc_port" \
--rpc.laddr "tcp://0.0.0.0:$celestia_app_host_port" \
--api.enable \
--grpc.enable \
--grpc-web.enable
1 change: 1 addition & 0 deletions charts/celestia-local/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ data:
home_dir: "/home/celestia"
coins: "{{ .Values.coins }}"
validator_stake: "{{ .Values.validatorStake }}"
validator_mnemonic: "{{ .Values.validatorMnemonic }}"
chainid: "{{ .Values.chainId }}"
keyring_backend: "{{ .Values.keyringBackend }}"
validator_key_name: "{{ .Values.validatorKeyName }}"
Expand Down
7 changes: 4 additions & 3 deletions charts/celestia-local/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ storage:
persistentVolumeName: "celestia-shared-storage"
path: "/data/celestia-data"

celestiaAppImage: "ghcr.io/celestiaorg/celestia-app:v1.3.0"
celestiaAppImage: "ghcr.io/celestiaorg/celestia-app:v1.8.0"
celestiaNodeImage: "ghcr.io/celestiaorg/celestia-node:v0.12.4"
tokenServerImage: "busybox:1.35.0-musl"

Expand All @@ -29,12 +29,13 @@ evmAddress: "0x966e6f22781EF6a6A82BBB4DB3df8E225DfD9488"
# Default private key, must correspond with above address
privateKey: "da6ed55cb2894ac2c9c10209c09de8e8b9d109b910338d5bf3d747a7e1fc9eb9"
# Default chain id
chainId: "test"
chainId: "celestia-local-0"
# Signer info
keyringBackend: "test"
validatorKeyName: "validator"
validatorMnemonic: connect soon random stable toddler tired glove drastic comfort donor struggle island cactus pole shell alpha taste able story business cross dismiss book brass
# Genesis amount
coins: "1000000000000000utia"
coins: "10000000000000000000000000utia"
# Staking amount
validatorStake: "5000000000utia"

Expand Down
Empty file added charts/hermes/.helmignore
Empty file.
30 changes: 30 additions & 0 deletions charts/hermes/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: v2
name: hermes
description: A Helm chart for deploying a k8s node of hermes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.8.2"

maintainers:
- name: wafflesvonmaple
url: astria.org
- name: joroshiba
url: astria.org
146 changes: 146 additions & 0 deletions charts/hermes/files/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
[global]
log_level = '{{ .Values.global.logLevel }}'

[rest]

# Whether or not to enable the REST service. Default: false
enabled = {{ .Values.rest.enabled }}

# Specify the IPv4/6 host over which the built-in HTTP server will serve the RESTful
# API requests. Default: 127.0.0.1
host = '127.0.0.1'

# Specify the port over which the built-in HTTP server will serve the restful API
# requests. Default: 3000
port = {{ .Values.ports.rest }}

[mode]

[mode.clients]
enabled = {{ .Values.mode.clients.enabled }}
refresh = {{ .Values.mode.clients.refresh }}
misbehaviour = {{ .Values.mode.clients.misbehaviour }}

[mode.connections]
enabled = {{ .Values.mode.connections.enabled }}

[mode.channels]
enabled = {{ .Values.mode.channels.enabled }}

[mode.packets]
enabled = {{ .Values.mode.packets.enabled }}
clear_interval = {{ .Values.mode.packets.clearInterval }}
clear_on_start = {{ .Values.mode.packets.clearOnStart }}
tx_confirmation = {{ .Values.mode.packets.txConfirmation }}

[telemetry]
enabled = {{ .Values.telemetry.enabled }}
host = '127.0.0.1'
port = {{ .Values.ports.telemetry }}

[telemetry.buckets]
latency_submitted = { start = {{ .Values.telemetry.latencySubmittedBuckets.start }}, end = {{ .Values.telemetry.latencySubmittedBuckets.end }}, buckets = {{ .Values.telemetry.latencySubmittedBuckets.count }} }
latency_confirmed = { start = {{ .Values.telemetry.latencyConfirmedBuckets.start }}, end = {{ .Values.telemetry.latencyConfirmedBuckets.end }}, buckets = {{ .Values.telemetry.latencyConfirmedBuckets.count }} }

[tracing_server]
enabled = {{ .Values.tracingServer.enabled }}
port = {{ .Values.ports.tracingServer }}

{{ range $chainId, $chain := .Values.chains}}
[[chains]]
id = '{{ $chainId }}'
type = '{{ $chain.type }}'
rpc_addr = '{{ $chain.rpcAddr }}'
grpc_addr = '{{ $chain.grpcAddr }}'
rpc_timeout = '{{ $chain.rpcTimeout }}'
account_prefix = '{{ $chain.accountPrefix }}'
key_name = '{{ $chain.key.name }}'
store_prefix = '{{ $chain.storePrefix }}'
ccv_consumer_chain = {{ default false $chain.ccvConsumerChain }}
ccv_consumer_chain = {{ default false $chain.trustedNode }}
{{- if eq $chain.eventSource.mode "push" }}
event_source = { mode = 'push', url = '{{ $chain.eventSource.url }}', batch_delay='{{ $chain.eventSource.batchDelay }}' }
{{- else if eq $chain.eventSource.mode "pull" }}
event_source = { mode = 'pull', interval = '{{ $chain.eventSource.interval }}' }
{{- end }}
{{- if $chain.addressType }}
{{- if eq $chain.addressType.derivation "cosmos" }}
address_type = { derivation = 'cosmos' }
{{- else if eq $chain.addressType.derivation "ethermint" }}
address_type = { derivation = 'ethermint', proto_type = { pk_type = '{{ $chain.addressType.protoType.pkType }}' }
{{- end }}
{{- end }}

gas_price = { price = {{ $chain.gasPrice }}, denom = '{{ $chain.gasDenom }}' }
{{- if $chain.defaultGas }}
default_gas = {{ $chain.defaultGas }}
{{- end }}
{{ if $chain.gasMultiplier }}
gas_multiplier = {{ $chain.gasMultiplier }}
{{- end }} # not used
{{- if $chain.maxGas }}
max_gas = {{ $chain.maxGas }}
{{ end }}
{{- if $chain.dynamicGasPrice }}
dynamic_gas_price = { enabled = true, multiplier = {{ $chain.dynamicGasPrice.multiplier }}, max = {{ $chain.dynamicGasPrice.max }} }
{{- end }}
{{- if $chain.maxMsgNumber }}
max_msg_number = {{ $chain.maxMsgNumber }}
{{- end }}
{{- if $chain.maxTxSize }}
max_tx_size = {{ $chain.maxTxSize }}
{{- end }}
{{- if $chain.queryPacketsChunkSize }}
query_packets_chunk_size = {{ $chain.queryPacketsChunkSize }}
{{- end }}
{{- if $chain.clock_drift}}
clock_drift = '{{ $chain.clockDrift }}'
{{- end }}
{{- if $chain.maxBlockTime }}
max_block_time = '{{ $chain.maxBlockTime }}'
{{- end }}
{{- if $chain.trustingPeriod }}
trusting_period = '{{ $chain.trustingPeriod }}'
{{- end }}
{{- if $chain.clientRefreshRate }}
client_refresh_rate = '{{ $chain.clientRefreshRate }}'
{{- end }}
{{- if $chain.trustThreshold }}
trust_threshold = '{{ $chain.trustThreshold }}'
{{- end }}
{{- if $chain.memoPrefix }}
memo_prefix = '{{ $chain.memoPrefix }}'
{{- end }}

{{- if $chain.packetFilter }}
{{- if $chain.packetFilter.policy }}
[[chains.packet_filter]]
policy = '{{ $chain.packetFilter.policy }}'
list = [
{{- range $index, $filter := $chain.packetFilter.list }}
['{{ $filter.portId }}', '{{ $filter.channelId }}'],
{{- end }}
]
{{- end }}
{{- if $chain.packetFilter.fees }}
{{- range $channel, $filter := $chain.packetFilter.fees }}
[[chains.packet_filter.min_fees.'{{ $channel }}']]
recv = [
{{- range $index, $denom := $filter.denoms }}
{ amount = '{{ $denom.amount }}' {{- if $denom.denom }}, denom = '{{ $denom.denom }}' {{- end }} },
{{- end }}
]
{{- end }}
{{- end }}
{{- end }}
{{- if $chain.feeGranter }}
fee_granter = '{{ $chain.feeGranter }}'
{{- end }}
{{- if $chain.compatMode }}
compat_mode = '{{ $chain.compatMode }}'
{{- end }}
{{- if $chain.clearInterval }}
clear_interval = '{{ $chain.clearInterval }}'
{{- end }}

{{ end }}
56 changes: 56 additions & 0 deletions charts/hermes/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{{/*
Namepsace to deploy elements into.
*/}}
{{- define "hermes.namespace" -}}
{{- default .Release.Namespace .Values.global.namespaceOverride | trunc 63 | trimSuffix "-" -}}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "hermes.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Return if ingress is stable.
*/}}
{{- define "hermes.ingress.isStable" -}}
{{- eq (include "hermes.ingress.apiVersion" .) "networking.k8s.io/v1" }}
{{- end }}

{{/*
Return if ingress supports ingressClassName.
*/}}
{{- define "hermes.ingress.supportsIngressClassName" -}}
{{- or (eq (include "hermes.ingress.isStable" .) "true") (and (eq (include "hermes.ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18-0" .Capabilities.KubeVersion.Version)) }}
{{- end }}

{{/*
Return if ingress supports pathType.
*/}}
{{- define "hermes.ingress.supportsPathType" -}}
{{- or (eq (include "hermes.ingress.isStable" .) "true") (and (eq (include "hermes.ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18-0" .Capabilities.KubeVersion.Version)) }}
{{- end }}

Return the appropriate apiVersion for ingress.
*/}}
{{- define "hermes.ingress.apiVersion" -}}
{{- if and ($.Capabilities.APIVersions.Has "networking.k8s.io/v1") (semverCompare ">= 1.19-0" .Capabilities.KubeVersion.Version) }}
{{- print "networking.k8s.io/v1" }}
{{- else if $.Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" }}
{{- print "networking.k8s.io/v1beta1" }}
{{- else }}
{{- print "extensions/v1beta1" }}
{{- end }}
{{- end }}
32 changes: 32 additions & 0 deletions charts/hermes/templates/configmaps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "hermes.fullname" . }}-config
namespace: {{ include "hermes.namespace" . }}
data:
config.toml: |
{{- tpl (.Files.Get "files/config.toml") $ | nindent 4 }}
---
{{- if not .Values.secretProvider.enabled }}
{{- range $chainId, $chain := .Values.chains }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "hermes.fullname" $ }}-{{$chainId}}-key
namespace: {{ include "hermes.namespace" $ }}
data:
{{ $chain.key.name }}.json: |
{{- toPrettyJson $chain.key.content | nindent 4 }}
---
{{- end }}
{{- end }}
{{- if .Values.createChannel.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: hermes-create-channel-script
namespace: {{ include "hermes.namespace" . }}
data:
create_channel.sh: |
{{- tpl (.Files.Get "files/create_channel.sh") $ | nindent 4 }}
{{- end }}
Loading

0 comments on commit 6d25f2c

Please sign in to comment.