diff --git a/charts/devnet/scripts/update-config.sh b/charts/devnet/scripts/update-config.sh index 38a5c2d38..23f7bad9a 100644 --- a/charts/devnet/scripts/update-config.sh +++ b/charts/devnet/scripts/update-config.sh @@ -71,5 +71,3 @@ sed -i -e "s#timeout_commit = \".*\"#timeout_commit = \"$TIMEOUT_COMMIT\"#g" $CH if [ "$METRICS" == "true" ]; then sed -i -e "s/prometheus = false/prometheus = true/g" $CHAIN_DIR/config/config.toml fi - -$CHAIN_BIN tendermint show-node-id diff --git a/charts/devnet/templates/_chains.tpl b/charts/devnet/templates/_chains.tpl new file mode 100644 index 000000000..01c4e88fe --- /dev/null +++ b/charts/devnet/templates/_chains.tpl @@ -0,0 +1,60 @@ +{{/* +Given a chain name, create a fullchain dict and return +Usage: +{{ include "devnet.getchain" (dict "name" cosmoshub-4 "file" $.File "context" $) }} +*/}} +{{- define "devnet.getchain" -}} +{{- $defaultFile := $.file -}} +{{- required "default file must have setup" $defaultFile.defaultChains -}} +{{- $chain := dict -}} +{{- range $chainIter := $.context.Values.chains -}} +{{- if eq $chainIter.name $.name -}} +{{- $chain = $chainIter | deepCopy -}} +{{- end }} +{{- end }} +{{- required "chain need to exist" $chain.type -}} + +{{- $defaultChain := get $defaultFile.defaultChains $chain.type | default dict -}} + +{{/* merge defaultChain values into the $chain dict*/}} +{{- $chain = merge $chain $defaultChain -}} + +{{ $_ := set $chain "hostname" (include "devnet.chain.name" $chain.name) }} + +{{- $faucet := get $chain "faucet" | default dict -}} +{{- $faucet = mergeOverwrite ($.context.Values.faucet | deepCopy) $faucet -}} +{{- $defaultFaucet := get $defaultFile.defaultFaucet $faucet.type | default dict -}} +{{- $faucet = merge $faucet $defaultFaucet -}} +{{ $_ = set $chain "faucet" $faucet -}} + +{{- if not (hasKey $chain "upgrade")}} +{{ $_ = set $chain "upgrade" (dict "enabled" false) }} +{{- end }} + +{{- if not (hasKey $chain "build")}} +{{ $_ = set $chain "build" (dict "enabled" false) }} +{{- end }} + +{{- $toBuild := or $chain.build.enabled $chain.upgrade.enabled -}} +{{- $_ = set $chain "toBuild" $toBuild -}} +{{- if $toBuild -}} +{{- $_ = set $chain "image" "ghcr.io/cosmology-tech/starship/runner:latest" -}} +{{- end }} + +{{- $defaultScripts := $defaultFile.defaultScripts }} +{{- $scripts := get $chain "scripts" | default dict }} +{{- $scripts = merge $scripts $defaultScripts }} +{{- $_ = set $chain "scripts" $scripts }} + +{{ println "@return" }} +{{ mustToJson $chain }} +{{- end -}} + +{{/* +Given a chain name, create a fullchain dict and return. Wraper +Usage: +{{ include "devnet.fullchain" (dict "name" cosmoshub-4 "file" $defaultFile "context" $) | fromtJson }} +*/}} +{{- define "devnet.fullchain"}} +{{ index (splitList "@return\n" (include "devnet.getchain" .)) 1 }} +{{- end }} diff --git a/charts/devnet/templates/_helpers.tpl b/charts/devnet/templates/_helpers.tpl index da7f716b8..d1f3644f7 100644 --- a/charts/devnet/templates/_helpers.tpl +++ b/charts/devnet/templates/_helpers.tpl @@ -278,3 +278,45 @@ Usage: {{- $tag := regexFind "[^:]+$" . -}} {{ $tag }} {{- end -}} + +{{/* +Given a chain name, create a fullchain dict and return +Usage: +{{ include "devnet.fullchain" (dict "name" cosmoshub-4 "file" $.File "context" $) }} +*/}} +{{- define "devnet.getchain" -}} +{{- $defaultFile := $.file -}} +{{- required "default file must have setup" $defaultFile.defaultChains -}} +{{- $chain := dict -}} +{{- range $chainIter := $.context.Values.chains -}} +{{- if eq $chainIter.name $.name -}} +{{- $chain = $chainIter | deepCopy -}} +{{- end }} +{{- end }} +{{- required "chain need to exist" $chain.type -}} + +{{- $defaultChain := get $defaultFile.defaultChains $chain.type | default dict -}} + +{{/* merge defaultChain values into the $chain dict*/}} +{{- $chain = merge $chain $defaultChain -}} + +{{- $faucet := get $chain "faucet" | default dict -}} +{{- $faucet = mergeOverwrite ($.context.Values.faucet | deepCopy) $faucet -}} +{{- $defaultFaucet := get $defaultFile.defaultFaucet $faucet.type | default dict -}} +{{- $faucet = merge $faucet $defaultFaucet -}} +{{ $_ := set $chain "faucet" $faucet -}} + +{{- $upgrade := $chain.upgrade | default (dict "enabled" false) -}} +{{- $build := .build | default (dict "enabled" false) -}} +{{- $toBuild := or $build.enabled $upgrade.enabled -}} +{{- $_ = set $chain "toBuild" $toBuild -}} +{{- if $toBuild -}} +{{- $_ = set $chain "image" "ghcr.io/cosmology-tech/starship/runner:latest" -}} +{{- end }} +{{ println "@return" }} +{{ mustToJson $chain }} +{{- end -}} + +{{- define "devnet.fullchain"}} +{{ index (splitList "@return\n" (include "devnet.getchain" .)) 1 }} +{{- end }} diff --git a/charts/devnet/templates/chains/cosmos/configmap.yaml b/charts/devnet/templates/chains/cosmos/configmap.yaml index 112bea0c7..d474d2b80 100644 --- a/charts/devnet/templates/chains/cosmos/configmap.yaml +++ b/charts/devnet/templates/chains/cosmos/configmap.yaml @@ -1,21 +1,14 @@ {{- range $chain := .Values.chains }} {{- if ne $chain.type "virtual" }} {{ $defaultFile := $.Files.Get "defaults.yaml" | fromYaml }} -{{ $defaultScripts := $defaultFile.defaultScripts }} -{{ $defaultChain := get $defaultFile.defaultChains $chain.type | default dict }} - -# merge defaultChain values into the $chain dict -{{ $chain = merge $chain $defaultChain }} - -{{ $scripts := get $chain "scripts" | default dict }} -{{ $scripts = merge $scripts $defaultScripts }} +{{ $chain := include "devnet.fullchain" (dict "name" $chain.name "file" $defaultFile "context" $) | fromJson }} --- apiVersion: v1 kind: ConfigMap metadata: name: setup-scripts-{{- include "devnet.chain.name" $chain.name }} data: - {{- range $k, $v := $scripts }} + {{- range $k, $v := $chain.scripts }} {{- if hasKey $v "data" }} {{ $v.name }}: |- {{- $v.data | nindent 4 }} @@ -25,23 +18,12 @@ data: {{- end }} {{- end }} --- -{{- end }} -{{- end }} ---- -{{- range $chain := .Values.chains }} -{{- if ne $chain.type "virtual" }} -{{ $defaultFile := $.Files.Get "defaults.yaml" | fromYaml }} -{{ $defaultScripts := $defaultFile.defaultScripts }} -{{ $defaultChain := get $defaultFile.defaultChains $chain.type | default dict }} - -# merge defaultChain values into the $chain dict -{{ $chain = merge $chain $defaultChain }} {{- if hasKey $chain "genesis" }} --- apiVersion: v1 kind: ConfigMap metadata: - name: patch-{{- include "devnet.chain.name" $chain.name }} + name: patch-{{ $chain.hostname }} data: genesis.json: |- {{ toJson $chain.genesis | nindent 4 }} diff --git a/charts/devnet/templates/chains/cosmos/genesis.yaml b/charts/devnet/templates/chains/cosmos/genesis.yaml index 7af331425..175b65d60 100644 --- a/charts/devnet/templates/chains/cosmos/genesis.yaml +++ b/charts/devnet/templates/chains/cosmos/genesis.yaml @@ -2,33 +2,15 @@ {{- if ne $chain.type "virtual" }} {{ $dataExposer := dict "chain" $chain.name "port" ($.Values.exposer.ports.rest | quote | default "8081") }} {{ $defaultFile := $.Files.Get "defaults.yaml" | fromYaml }} -{{ $defaultChain := get $defaultFile.defaultChains $chain.type | default dict }} -# merge defaultChain values into the $chain dict -{{ $chain = merge $chain $defaultChain }} - -{{- $upgrade := $chain.upgrade | default (dict "enabled" false) }} -{{- $build := .build | default (dict "enabled" false) -}} -{{- $toBuild := or $build.enabled $upgrade.enabled }} - -# read faucet from chain values and merge with default faucet values -{{ $faucet := get $chain "faucet" | default dict }} -{{ $faucet = mergeOverwrite ($.Values.faucet | deepCopy) $faucet }} - -{{ $defaultFaucet := get $defaultFile.defaultFaucet $faucet.type | default dict }} -{{ $faucet = merge $faucet $defaultFaucet }} - -{{ $image := $chain.image }} -{{- if $toBuild }} -{{ $image = "ghcr.io/cosmology-tech/starship/runner:latest" }} -{{- end }} +{{ $chain := include "devnet.fullchain" (dict "name" $chain.name "file" $defaultFile "context" $) | fromJson }} --- apiVersion: apps/v1 kind: StatefulSet metadata: - name: {{ include "devnet.chain.name" $chain.name }}-genesis + name: {{ $chain.hostname }}-genesis spec: - serviceName: {{ include "devnet.chain.name" $chain.name }}-genesis + serviceName: {{ $chain.hostname }}-genesis replicas: 1 revisionHistoryLimit: 3 selector: @@ -51,7 +33,7 @@ spec: spec: {{- include "imagePullSecrets" $chain | indent 6 }} initContainers: - {{- if $toBuild }} + {{- if $chain.toBuild }} - name: init-build-images image: ghcr.io/cosmology-tech/starship/builder:latest imagePullPolicy: IfNotPresent @@ -63,12 +45,12 @@ spec: go install github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor@v1.0.0 # Build genesis - {{- if $upgrade.enabled }} + {{- if $chain.upgrade.enabled }} UPGRADE_NAME=genesis CODE_TAG={{ $chain.upgrade.genesis }} bash -e /scripts/build-chain.sh {{- range $upgrade := $chain.upgrade.upgrades }} UPGRADE_NAME={{ $upgrade.name }} CODE_TAG={{ $upgrade.version }} bash -e /scripts/build-chain.sh {{- end }} - {{- else if $build.enabled }} + {{- else if $chain.build.enabled }} UPGRADE_NAME=genesis CODE_TAG={{ $chain.build.source }} bash -e /scripts/build-chain.sh {{- end }} env: @@ -91,7 +73,7 @@ spec: name: scripts {{- end }} - name: init-genesis - image: {{ $image }} + image: {{ $chain.image }} imagePullPolicy: Always env: {{- include "devnet.defaultEvnVars" $chain | indent 12 }} @@ -100,7 +82,7 @@ spec: - name: KEYS_CONFIG value: /configs/keys.json - name: FAUCET_ENABLED - value: "{{ $faucet.enabled }}" + value: "{{ $chain.faucet.enabled }}" - name: NUM_VALIDATORS value: "{{ $chain.numValidators }}" command: @@ -109,7 +91,7 @@ spec: - | VAL_INDEX=${HOSTNAME##*-} echo "Validator Index: $VAL_INDEX" - {{- if $toBuild }} + {{- if $chain.toBuild }} cp $CHAIN_DIR/cosmovisor/genesis/bin/$CHAIN_BIN /usr/bin {{- end }} @@ -130,7 +112,7 @@ spec: - mountPath: /scripts name: scripts - name: init-config - image: {{ $image }} + image: {{ $chain.image }} imagePullPolicy: Always env: {{- include "devnet.defaultEvnVars" $chain | indent 12 }} @@ -146,6 +128,9 @@ spec: - | VAL_INDEX=${HOSTNAME##*-} echo "Validator Index: $VAL_INDEX" + {{- if $chain.toBuild }} + cp $CHAIN_DIR/cosmovisor/genesis/bin/$CHAIN_BIN /usr/bin + {{- end }} echo "Running setup config script..." {{- if hasKey $chain "genesis" }} @@ -165,9 +150,9 @@ spec: name: patch {{- end }} {{/*if faucet is of type starship, then initialize faucet binary*/}} - {{- if and ($faucet.enabled) (eq $faucet.type "starship") }} + {{- if and ($chain.faucet.enabled) (eq $chain.faucet.type "starship") }} - name: init-faucet - image: {{ $faucet.image }} + image: {{ $chain.faucet.image }} imagePullPolicy: IfNotPresent command: - bash @@ -183,18 +168,18 @@ spec: {{- end }} containers: - name: validator - image: {{ $image }} + image: {{ $chain.image }} imagePullPolicy: Always env: {{- include "devnet.defaultEvnVars" $chain | indent 12 }} {{- include "devnet.evnVars" $chain | indent 12 }} - name: FAUCET_ENABLED - value: "{{ $faucet.enabled }}" + value: "{{ $chain.faucet.enabled }}" command: - bash - "-c" - | - {{- if $toBuild }} + {{- if $chain.toBuild }} /usr/bin/cosmovisor start {{- else }} $CHAIN_BIN start @@ -233,16 +218,16 @@ spec: name: node - mountPath: /configs name: addresses - {{- if $faucet.enabled }} - {{- if eq $faucet.type "cosmjs" }} + {{- if $chain.faucet.enabled }} + {{- if eq $chain.faucet.type "cosmjs" }} - name: faucet - image: {{ $faucet.image }} + image: {{ $chain.faucet.image }} imagePullPolicy: Always env: - name: FAUCET_CONCURRENCY - value: "{{ $faucet.concurrency }}" + value: "{{ $chain.faucet.concurrency }}" - name: FAUCET_PORT - value: "{{ $faucet.ports.rest }}" + value: "{{ $chain.faucet.ports.rest }}" - name: FAUCET_MEMO value: "faucet txn" - name: FAUCET_GAS_PRICE @@ -285,22 +270,22 @@ spec: volumeMounts: - mountPath: /configs name: addresses - resources: {{- include "getResourceObject" $faucet.resources | trim | nindent 12 }} + resources: {{- include "getResourceObject" $chain.faucet.resources | trim | nindent 12 }} readinessProbe: httpGet: path: /status - port: {{ $faucet.ports.rest }} + port: {{ $chain.faucet.ports.rest }} initialDelaySeconds: 10 periodSeconds: 10 - {{- else if eq $faucet.type "starship" }} + {{- else if eq $chain.faucet.type "starship" }} - name: faucet - image: {{ $image }} + image: {{ $chain.image }} imagePullPolicy: Always env: - name: FAUCET_CONCURRENCY - value: "{{ $faucet.concurrency }}" + value: "{{ $chain.faucet.concurrency }}" - name: FAUCET_HTTP_PORT - value: "{{ $faucet.ports.rest }}" + value: "{{ $chain.faucet.ports.rest }}" - name: FAUCET_CHAIN_BINARY value: "{{ $chain.binary }}" - name: FAUCET_CHAIN_ID @@ -337,11 +322,11 @@ spec: name: addresses - mountPath: /faucet name: faucet - resources: {{- include "getResourceObject" $faucet.resources | trim | nindent 12 }} + resources: {{- include "getResourceObject" $chain.faucet.resources | trim | nindent 12 }} readinessProbe: httpGet: path: /status - port: {{ $faucet.ports.rest }} + port: {{ $chain.faucet.ports.rest }} initialDelaySeconds: 10 periodSeconds: 10 {{- end }} @@ -360,7 +345,7 @@ spec: configMap: name: patch-{{- include "devnet.chain.name" $chain.name }} {{- end }} - {{- if and ($faucet.enabled) (eq $faucet.type "starship") }} + {{- if and ($chain.faucet.enabled) (eq $chain.faucet.type "starship") }} - name: faucet emptyDir: { } {{- end }} diff --git a/charts/devnet/templates/chains/cosmos/service.yaml b/charts/devnet/templates/chains/cosmos/service.yaml index 1d9c92bf4..0ae38d720 100644 --- a/charts/devnet/templates/chains/cosmos/service.yaml +++ b/charts/devnet/templates/chains/cosmos/service.yaml @@ -1,7 +1,6 @@ {{ $portMap := dict "p2p" 26656 "rpc" 26657 "grpc" 9090 "rest" 1317 }} {{- range $chain := .Values.chains }} {{- if ne $chain.type "virtual" }} - --- apiVersion: v1 kind: Service diff --git a/charts/devnet/templates/chains/cosmos/validator.yaml b/charts/devnet/templates/chains/cosmos/validator.yaml index ae14a226c..1b27274f6 100644 --- a/charts/devnet/templates/chains/cosmos/validator.yaml +++ b/charts/devnet/templates/chains/cosmos/validator.yaml @@ -3,34 +3,17 @@ {{- if gt $chain.numValidators 1.0 }} {{ $dataExposer := dict "chain" $chain.name "port" ($.Values.exposer.ports.rest | quote | default "8081") }} {{ $defaultFile := $.Files.Get "defaults.yaml" | fromYaml }} -{{ $defaultChain := get $defaultFile.defaultChains $chain.type | default dict }} -# merge defaultChain values into the $chain dict -{{ $chain = merge $chain $defaultChain }} -{{- $upgrade := $chain.upgrade | default (dict "enabled" false) }} -{{- $build := .build | default (dict "enabled" false) -}} -{{- $toBuild := or $build.enabled $upgrade.enabled }} - -# read faucet from chain values and merge with default faucet values -{{ $faucet := get $chain "faucet" | default dict }} -{{ $faucet = mergeOverwrite ($.Values.faucet | deepCopy) $faucet }} - -{{ $defaultFaucet := get $defaultFile.defaultFaucet $faucet.type | default dict }} -{{ $faucet = merge $faucet $defaultFaucet }} - -{{ $image := $chain.image }} -{{- if $toBuild }} -{{ $image = "ghcr.io/cosmology-tech/starship/runner:latest" }} -{{- end }} +{{ $chain := include "devnet.fullchain" (dict "name" $chain.name "file" $defaultFile "context" $) | fromJson }} {{ $initParams := dict "chains" (list $chain.name) "port" $.Values.exposer.ports.rest "context" $ }} --- apiVersion: apps/v1 kind: StatefulSet metadata: - name: {{ include "devnet.chain.name" $chain.name }}-validator + name: {{ $chain.hostname }}-validator spec: - serviceName: {{ include "devnet.chain.name" $chain.name }}-validator + serviceName: {{ $chain.hostname }}-validator podManagementPolicy: Parallel replicas: {{ sub $chain.numValidators 1 }} revisionHistoryLimit: 3 @@ -53,7 +36,7 @@ spec: spec: {{- include "imagePullSecrets" $chain | indent 6 }} initContainers: - {{- if $toBuild }} + {{- if $chain.toBuild }} - name: init-build-images image: ghcr.io/cosmology-tech/starship/builder:latest imagePullPolicy: IfNotPresent @@ -65,12 +48,12 @@ spec: go install github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor@v1.0.0 # Build genesis - {{- if $upgrade.enabled }} + {{- if $chain.upgrade.enabled }} UPGRADE_NAME=genesis CODE_TAG={{ $chain.upgrade.genesis }} bash -e /scripts/build-chain.sh {{- range $upgrade := $chain.upgrade.upgrades }} UPGRADE_NAME={{ $upgrade.name }} CODE_TAG={{ $upgrade.version }} bash -e /scripts/build-chain.sh {{- end }} - {{- else if $build.enabled }} + {{- else if $chain.build.enabled }} UPGRADE_NAME=genesis CODE_TAG={{ $chain.build.source }} bash -e /scripts/build-chain.sh {{- end }} env: @@ -94,7 +77,7 @@ spec: {{- end }} {{- include "devnet.init.wait" $initParams | indent 8 }} - name: init-validator - image: {{ $image }} + image: {{ $chain.image }} imagePullPolicy: Always env: {{- include "devnet.defaultEvnVars" $chain | indent 12 }} @@ -104,7 +87,7 @@ spec: - name: KEYS_CONFIG value: /configs/keys.json - name: FAUCET_ENABLED - value: "{{ $faucet.enabled }}" + value: "{{ $chain.faucet.enabled }}" - name: METRICS value: "{{ $chain.metrics }}" command: @@ -113,7 +96,7 @@ spec: - | VAL_INDEX=${HOSTNAME##*-} echo "Validator Index: $VAL_INDEX" - {{- if $toBuild }} + {{- if $chain.toBuild }} cp $CHAIN_DIR/cosmovisor/genesis/bin/$CHAIN_BIN /usr/bin {{- end }} @@ -141,7 +124,7 @@ spec: - mountPath: /scripts name: scripts - name: init-config - image: {{ $image }} + image: {{ $chain.image }} imagePullPolicy: Always env: {{- include "devnet.defaultEvnVars" $chain | indent 12 }} @@ -158,6 +141,9 @@ spec: - | VAL_INDEX=${HOSTNAME##*-} echo "Validator Index: $VAL_INDEX" + {{- if $chain.toBuild }} + cp $CHAIN_DIR/cosmovisor/genesis/bin/$CHAIN_BIN /usr/bin + {{- end }} echo "Running setup config script..." bash -e /scripts/update-config.sh @@ -185,7 +171,7 @@ spec: name: scripts containers: - name: validator - image: {{ $image }} + image: {{ $chain.image }} imagePullPolicy: Always env: {{- include "devnet.defaultEvnVars" $chain | indent 12 }} @@ -198,7 +184,7 @@ spec: - "-c" - | # Starting the chain - {{- if $toBuild }} + {{- if $chain.toBuild }} cp $CHAIN_DIR/cosmovisor/genesis/bin/$CHAIN_BIN /usr/bin /usr/bin/cosmovisor start {{- else }} @@ -222,7 +208,7 @@ spec: $VAL_ADDR \ $DENOM \ http://$GENESIS_HOST.$NAMESPACE.svc.cluster.local:8000/credit \ - "{{ $faucet.enabled }}" || true + "{{ $chain.faucet.enabled }}" || true $CHAIN_BIN keys list --keyring-backend test | jq @@ -271,7 +257,7 @@ spec: name: keys - name: scripts configMap: - name: setup-scripts-{{- include "devnet.chain.name" $chain.name }} + name: setup-scripts-{{ $chain.hostname }} --- {{- end }} {{- end }} diff --git a/charts/devnet/templates/explorer.yaml b/charts/devnet/templates/explorer.yaml index 72e8aee0f..bc86f8361 100644 --- a/charts/devnet/templates/explorer.yaml +++ b/charts/devnet/templates/explorer.yaml @@ -76,13 +76,12 @@ kind: ConfigMap metadata: name: explorer data: - {{- range $chain := .Values.chains }} {{ $defaultFile := $.Files.Get "defaults.yaml" | fromYaml }} - {{ $defaultChain := get $defaultFile.defaultChains $chain.type | default dict }} - {{ $chain = merge $chain $defaultChain }} + {{- range $chain := .Values.chains }} + {{ $chain := include "devnet.fullchain" (dict "name" $chain.name "file" $defaultFile "context" $) | fromJson }} {{ $host := "localhost" }} {{- if not $.Values.explorer.localhost }} - {{ $host := printf "%s-genesis.%s.svc.cluster.local" (include "devnet.chain.name" $chain.name) $.Release.Namespace }} + {{ $host := printf "%s-genesis.%s.svc.cluster.local" $chain.hostname $.Release.Namespace }} {{- end }} {{ $chain.name }}.json: |- { diff --git a/charts/devnet/templates/registry.yaml b/charts/devnet/templates/registry.yaml index 7ac61045c..19b014564 100644 --- a/charts/devnet/templates/registry.yaml +++ b/charts/devnet/templates/registry.yaml @@ -101,18 +101,17 @@ spec: name: registry-{{- include "devnet.chain.name" $chain.name }} {{- end }} --- -{{- range $chain := .Values.chains }} {{ $defaultFile := $.Files.Get "defaults.yaml" | fromYaml }} -{{ $defaultChain := get $defaultFile.defaultChains $chain.type | default dict }} -{{ $chain = merge $chain $defaultChain }} +{{- range $chain := .Values.chains }} +{{ $chain := include "devnet.fullchain" (dict "name" $chain.name "file" $defaultFile "context" $) | fromJson }} {{ $host := "localhost" }} {{- if not $.Values.registry.localhost }} -{{ $host := printf "%s-genesis.%s.svc.cluster.local" (include "devnet.chain.name" $chain.name) $.Release.Namespace }} +{{ $host := printf "%s-genesis.%s.svc.cluster.local" $chain.hostname $.Release.Namespace }} {{- end }} apiVersion: v1 kind: ConfigMap metadata: - name: registry-{{- include "devnet.chain.name" $chain.name }} + name: registry-{{ $chain.hostname }} data: assetlist.json: |- { diff --git a/charts/devnet/templates/relayers/go-relayer/configmap.yaml b/charts/devnet/templates/relayers/go-relayer/configmap.yaml index d829142fd..c1ecdc9f4 100644 --- a/charts/devnet/templates/relayers/go-relayer/configmap.yaml +++ b/charts/devnet/templates/relayers/go-relayer/configmap.yaml @@ -20,13 +20,9 @@ data: "channel-list": [] } } - - {{- range $i, $chain := $relayer.chains }} - {{- range $fullchain := $.Values.chains }} - {{- if eq $fullchain.name $chain }} {{ $defaultFile := $.Files.Get "defaults.yaml" | fromYaml }} - {{ $defaultChain := get $defaultFile.defaultChains $fullchain.type | default dict }} - {{ $fullchain = merge $fullchain $defaultChain }} + {{- range $i, $chain := $relayer.chains }} + {{ $fullchain := include "devnet.fullchain" (dict "name" $chain "file" $defaultFile "context" $) | fromJson }} {{ $fullchain.name }}.json: |- { "type": "cosmos", @@ -46,8 +42,6 @@ data: } } {{- end }} - {{- end }} - {{- end }} --- {{- end }} {{- end }} diff --git a/charts/devnet/templates/relayers/go-relayer/statefulset.yaml b/charts/devnet/templates/relayers/go-relayer/statefulset.yaml index bcec0f8ec..838777e9c 100644 --- a/charts/devnet/templates/relayers/go-relayer/statefulset.yaml +++ b/charts/devnet/templates/relayers/go-relayer/statefulset.yaml @@ -60,15 +60,8 @@ spec: rly config init {{- range $i, $chain := $relayer.chains }} - {{- range $fullchain := $.Values.chains }} - {{- if eq $fullchain.name $chain }} - {{ $defaultFile := $.Files.Get "defaults.yaml" | fromYaml }} - {{ $defaultChain := get $defaultFile.defaultChains $fullchain.type | default dict }} - {{ $fullchain = merge $fullchain $defaultChain }} - {{ $faucet := get $fullchain "faucet" | default dict }} - {{ $faucet = mergeOverwrite ($.Values.faucet | deepCopy) $faucet }} - {{ $defaultFaucet := get $defaultFile.defaultFaucet $faucet.type | default dict }} - {{ $faucet = merge $faucet $defaultFaucet }} + {{ $fullchain := include "devnet.fullchain" (dict "name" $chain "file" $defaultFile "context" $) | fromJson }} + echo "Adding {{ $fullchain.name }} chain" rly chains add --file "/configs/{{ $fullchain.name }}.json" {{ $fullchain.name }} @@ -82,9 +75,7 @@ spec: $RLY_ADDR \ $DENOM \ http://{{- include "devnet.chain.name" $fullchain.name }}-genesis.$NAMESPACE.svc.cluster.local:8000/credit \ - "{{ $faucet.enabled }}" - {{- end }} - {{- end }} + "{{ $fullchain.faucet.enabled }}" {{- end }} PATHEND="{{ index $relayer.chains 0 }}-{{ index $relayer.chains 1 }}" diff --git a/charts/devnet/templates/relayers/hermes/configmap.yaml b/charts/devnet/templates/relayers/hermes/configmap.yaml index c13a3810a..22abd0c69 100644 --- a/charts/devnet/templates/relayers/hermes/configmap.yaml +++ b/charts/devnet/templates/relayers/hermes/configmap.yaml @@ -83,24 +83,20 @@ data: # by the telemetry service. Default: 3001 port = {{ $relayer.config.telemetry.port }} {{- range $i, $chain := $relayer.chains }} - {{- range $fullchain := $.Values.chains }} - {{- if eq $fullchain.name $chain }} - {{ $defaultFile := $.Files.Get "defaults.yaml" | fromYaml }} - {{ $defaultChain := get $defaultFile.defaultChains $fullchain.type | default dict }} - {{ $fullchain = merge $fullchain $defaultChain }} + {{ $fullchain := include "devnet.fullchain" (dict "name" $chain "file" $defaultFile "context" $) | fromJson }} [[chains]] id = "{{ $chain }}" key_name = "{{ $chain }}" - rpc_addr = "http://{{ include "devnet.chain.name" $chain }}-genesis.{{ $.Release.Namespace }}.svc.cluster.local:26657" - grpc_addr = "http://{{ include "devnet.chain.name" $chain }}-genesis.{{ $.Release.Namespace }}.svc.cluster.local:9090" + rpc_addr = "http://{{ $fullchain.hostname }}-genesis.{{ $.Release.Namespace }}.svc.cluster.local:26657" + grpc_addr = "http://{{ $fullchain.hostname }}-genesis.{{ $.Release.Namespace }}.svc.cluster.local:9090" {{- if le (semver $tag | (semver "1.6.0").Compare) 0 }} {{- if eq $relayer.config.event_source.mode "pull" }} event_source = { mode = 'pull', interval = '500ms' } {{- else }} - event_source = { mode = 'push', url = "ws://{{ include "devnet.chain.name" $chain }}-genesis.{{ $.Release.Namespace }}.svc.cluster.local:26657/websocket", batch_delay = '500ms' } + event_source = { mode = 'push', url = "ws://{{ $fullchain.hostname }}-genesis.{{ $.Release.Namespace }}.svc.cluster.local:26657/websocket", batch_delay = '500ms' } {{- end }} {{- else }} - websocket_addr = "ws://{{ include "devnet.chain.name" $chain }}-genesis.{{ $.Release.Namespace }}.svc.cluster.local:26657/websocket" + websocket_addr = "ws://{{ $fullchain.hostname }}-genesis.{{ $.Release.Namespace }}.svc.cluster.local:26657/websocket" {{- end }} account_prefix = "{{ $fullchain.prefix }}" default_gas = 500000000 @@ -125,8 +121,6 @@ data: gas_price = { price = 0.25, denom = "{{ $fullchain.denom }}" } {{- end }} {{- end }} - {{- end }} - {{- end }} --- {{- end }} {{- end }} diff --git a/charts/devnet/templates/relayers/hermes/statefulset.yaml b/charts/devnet/templates/relayers/hermes/statefulset.yaml index e8932beaa..f0d8742ff 100644 --- a/charts/devnet/templates/relayers/hermes/statefulset.yaml +++ b/charts/devnet/templates/relayers/hermes/statefulset.yaml @@ -65,31 +65,26 @@ spec: echo $MNEMONIC > $RELAYER_DIR/mnemonic.txt {{- range $i, $chain := $relayer.chains }} - {{- range $fullchain := $.Values.chains }} - {{- if eq $fullchain.name $chain }} - {{ $defaultFile := $.Files.Get "defaults.yaml" | fromYaml }} - {{ $defaultChain := get $defaultFile.defaultChains $fullchain.type | default dict }} - {{ $fullchain = merge $fullchain $defaultChain }} - {{ $faucet := get $fullchain "faucet" | default dict }} - {{ $faucet = mergeOverwrite ($.Values.faucet | deepCopy) $faucet }} - {{ $defaultFaucet := get $defaultFile.defaultFaucet $faucet.type | default dict }} - {{ $faucet = merge $faucet $defaultFaucet }} + {{ $fullchain := include "devnet.fullchain" (dict "name" $chain "file" $defaultFile "context" $) | fromJson }} echo "Creating key for {{ $chain }}..." + cat << EOF + {{ typeOf $fullchain | indent 14 }} + {{ $fullchain | toJson | indent 14 }} + EOF hermes keys add \ --chain {{ $chain }} \ --mnemonic-file $RELAYER_DIR/mnemonic.txt \ - --key-name {{ $chain }} \ + --key-name {{ $chain }} --hd-path {{ $fullchain.hdPath | quote }} DENOM="{{ $fullchain.denom }}" RLY_ADDR=$(hermes --json keys list --chain {{ $chain }} | tail -1 | jq -r '.result."{{ $chain }}".account') echo "Transfer tokens to address $RLY_ADDR" + bash -e /scripts/transfer-tokens.sh \ $RLY_ADDR \ $DENOM \ - http://{{- include "devnet.chain.name" $fullchain.name }}-genesis.$NAMESPACE.svc.cluster.local:8000/credit \ - "{{ $faucet.enabled }}" - {{- end }} - {{- end }} + http://{{ $fullchain.hostname }}-genesis.$NAMESPACE.svc.cluster.local:8000/credit \ + "{{ $fullchain.faucet.enabled }}" {{- end }} hermes create channel \ diff --git a/charts/devnet/templates/relayers/ts-relayer/configmap.yaml b/charts/devnet/templates/relayers/ts-relayer/configmap.yaml index efae02de6..d694c98e0 100644 --- a/charts/devnet/templates/relayers/ts-relayer/configmap.yaml +++ b/charts/devnet/templates/relayers/ts-relayer/configmap.yaml @@ -15,14 +15,11 @@ data: registry.yaml: |- version: 1 chains: + {{ $defaultFile := $.Files.Get "defaults.yaml" | fromYaml }} {{- range $i, $chain := $relayer.chains }} + {{ $fullchain := include "devnet.fullchain" (dict "name" $chain "file" $defaultFile "context" $) | fromJson }} {{ $chain }}: - {{- range $fullchain := $.Values.chains }} - {{- if eq $fullchain.name $chain }} - {{ $defaultFile := $.Files.Get "defaults.yaml" | fromYaml }} - {{ $defaultChain := get $defaultFile.defaultChains $fullchain.type | default dict }} - {{ $fullchain = merge $fullchain $defaultChain }} - chain_id: {{ $chain }} + chain_id: {{ $chain }} # You can include multiple RPC endpoints and it will rotate through them if # one is down (TODO) rpc: @@ -39,8 +36,6 @@ data: ics20_port: 'transfer' estimated_block_time: {{ $.Values.timeouts.timeout_commit | toString | replace "ms" "" | float64 }} estimated_indexer_time: {{ $.Values.timeouts.time_iota_ms | toString | replace "ms" "" | float64 }} - {{- end }} - {{- end }} {{- end }} --- {{- end }} diff --git a/charts/devnet/templates/relayers/ts-relayer/statefulset.yaml b/charts/devnet/templates/relayers/ts-relayer/statefulset.yaml index 8b1795fc1..4634e9a4b 100644 --- a/charts/devnet/templates/relayers/ts-relayer/statefulset.yaml +++ b/charts/devnet/templates/relayers/ts-relayer/statefulset.yaml @@ -69,15 +69,7 @@ spec: sed -i -e "s//$MNEMONIC/g" $RELAYER_DIR/app.yaml {{- range $i, $chain := $relayer.chains }} - {{- range $fullchain := $.Values.chains }} - {{- if eq $fullchain.name $chain }} - {{ $defaultFile := $.Files.Get "defaults.yaml" | fromYaml }} - {{ $defaultChain := get $defaultFile.defaultChains $fullchain.type | default dict }} - {{ $fullchain = merge $fullchain $defaultChain }} - {{ $faucet := get $fullchain "faucet" | default dict }} - {{ $faucet = mergeOverwrite ($.Values.faucet | deepCopy) $faucet }} - {{ $defaultFaucet := get $defaultFile.defaultFaucet $faucet.type | default dict }} - {{ $faucet = merge $faucet $defaultFaucet }} + {{ $fullchain := include "devnet.fullchain" (dict "name" $chain "file" $defaultFile "context" $) | fromJson }} DENOM="{{ $fullchain.denom }}" RLY_ADDR=$(ibc-setup keys list | grep "{{ $fullchain.name }}" | awk '{print $2}') echo "Transfer tokens to address $RLY_ADDR" @@ -85,9 +77,7 @@ spec: $RLY_ADDR \ $DENOM \ http://{{- include "devnet.chain.name" $fullchain.name }}-genesis.$NAMESPACE.svc.cluster.local:8000/credit \ - "{{ $faucet.enabled }}" - {{- end }} - {{- end }} + "{{ $fullchain.faucet.enabled }}" {{- end }} if [ $RLY_INDEX -eq 0 ]; then