Skip to content

Commit

Permalink
add support for setting the database backend (rocksdb/paritydb)
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreBesson committed Jun 13, 2022
1 parent 917893b commit b775da1
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 8 deletions.
2 changes: 1 addition & 1 deletion charts/node/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ apiVersion: v2
name: node
description: A Helm chart to deploy Substrate/Polkadot nodes
type: application
version: 2.2.0
version: 2.3.0
5 changes: 3 additions & 2 deletions charts/node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,17 @@ node:
| `node.replica` | Number of replica in the node StatefulSet | `1` |
| `node.role` | Set the role of the node: `full`, `authority`/`validator`, `collator` or `light` | `full` |
| `node.chainDataSnapshotUrl` | Download and load chain data from a snapshot archive http URL | `` |
| `node.chainDataSnapshotFormat` | The snapshot archive format (`tar` or `lz4`) | `tar` |
| `node.chainDataSnapshotFormat` | The snapshot archive format (`tar` or `lz4`) | `tar` |
| `node.chainDataGcsBucketUrl` | Sync chain data files from a GCS bucket (eg. `gs://bucket-name/folder-name`) | `` |
| `node.chainPath` | Path at which the chain database files are located (`/data/chains/${CHAIN_PATH}`) | `nil` (if undefined, fallbacks to the value in `node.chain`) |
| `node.chainDataKubernetesVolumeSnapshot` | Initialize the chain data volume from a Kubernetes VolumeSnapshot | `` |
| `node.customChainspecUrl` | Download and use a custom chainspec file from a URL | `nil` |
| `node.database` | Set the database backend to use and that will be passed to the `--database` flag (`rocksdb`, `paritydb` or `nil`) | `nil` |
| `node.forceDownloadChainspec` | Force the chainspec download even if it is already present on the volume | `false` |
| `node.collator.isParachain` | If true, configure the node as a parachain (set the relay-chain flags after `--`) | `nil` |
| `node.collator.relayChainCustomChainspecUrl` | Download and use a custom relay-chain chainspec file from a URL | `nil` |
| `node.collator.relayChainDataSnapshotUrl` | Download and load relay-chain data from a snapshot archive http URL | `nil` |
| `node.collator.relayChainDataSnapshotFormat` | The relay-chain snapshot archive format (`tar` or `lz4`) | `nil` |
| `node.collator.relayChainDataSnapshotFormat` | The relay-chain snapshot archive format (`tar` or `lz4`) | `nil` |
| `node.collator.relayChainPath` | Path at which the chain database files are located (`/data/polkadot/chains/${RELAY_CHAIN_PATH}`) | `nil` |
| `node.collator.relayChainDataKubernetesVolumeSnapshot` | Initialize the relay-chain data volume from a Kubernetes VolumeSnapshot | `nil` |
| `node.collator.relayChainDataGcsBucketUrl` | Sync relay-chain data files from a GCS bucket (eg. `gs://bucket-name/folder-name`) | `nil` |
Expand Down
14 changes: 14 additions & 0 deletions charts/node/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ pruning: archive
unsafe-pruning: false
{{- end }}
{{- end }}
{{- if .Values.node.database }}
database: {{ .Values.node.database }}
{{- end }}
{{- end }}

{{/*
Expand Down Expand Up @@ -82,3 +85,14 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Create the database path depending on the database backend in use (rocksdb or paritydb)
*/}}
{{- define "node.databasePath" -}}
{{- if eq .Values.node.database "paritydb" }}
{{- "paritydb" }}
{{- else }}
{{- "db" }}
{{- end }}
{{- end }}
14 changes: 9 additions & 5 deletions charts/node/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{{ $selectorLabels := include "node.selectorLabels" . }}
{{ $serviceLabels := include "node.serviceLabels" . }}
{{ $serviceAccountName := include "node.serviceAccountName" . }}
{{ $databasePath := include "node.databasePath" . }}
apiVersion: apps/v1
kind: StatefulSet
metadata:
Expand Down Expand Up @@ -78,11 +79,11 @@ spec:
else
echo "Downloading chain snapshot"
SNAPSHOT_URL="{{ .Values.node.chainDataSnapshotUrl }}"
mkdir -p /data/chains/${CHAIN_PATH}/db/
mkdir -p /data/chains/${CHAIN_PATH}/{{ $databasePath }}/
if [ "${SNAPSHOT_FORMAT}" == "lz4" ]; then
wget -O - ${SNAPSHOT_URL} | lz4 -c -d - | tar -x -C /data/chains/${CHAIN_PATH}/
else
wget -O - ${SNAPSHOT_URL} | tar -x -C /data/chains/${CHAIN_PATH}/db/
wget -O - ${SNAPSHOT_URL} | tar -x -C /data/chains/${CHAIN_PATH}/{{ $databasePath }}/
fi
fi
env:
Expand Down Expand Up @@ -111,7 +112,7 @@ spec:
if [ "${RELAY_SNAPSHOT_FORMAT}" == "lz4" ]; then
wget -O - ${RELAY_SNAPSHOT_URL} | lz4 -c -d - | tar -x -C /data/chains/${RELAY_CHAIN_PATH}/
else
wget -O - ${RELAY_SNAPSHOT_URL} | tar -x -C /data/chains/${RELAY_CHAIN_PATH}/db/
wget -O - ${RELAY_SNAPSHOT_URL} | tar -x -C /data/chains/${RELAY_CHAIN_PATH}/{{ $databasePath }}/
fi
fi
env:
Expand Down Expand Up @@ -144,7 +145,7 @@ spec:
exit 1
fi
mkdir -p /data/chains/${CHAIN_PATH}/db
gsutil -m -o "GSUtil:parallel_process_count=3" -o "GSUtil:parallel_thread_count=15" rsync -d -r ${BUCKET_URL}/${LATEST} /data/chains/${CHAIN_PATH}/db/
gsutil -m -o "GSUtil:parallel_process_count=3" -o "GSUtil:parallel_thread_count=15" rsync -d -r ${BUCKET_URL}/${LATEST} /data/chains/${CHAIN_PATH}/{{ $databasePath }}/
fi
env:
- name: CHAIN_PATH
Expand Down Expand Up @@ -179,7 +180,7 @@ spec:
exit 1
fi
mkdir -p /data/relay/chains/${RELAY_CHAIN_PATH}/db
gsutil -m -o "GSUtil:parallel_process_count=3" -o "GSUtil:parallel_thread_count=15" rsync -d -r ${BUCKET_URL}/${LATEST} /data/relay/chains/${RELAY_CHAIN_PATH}/db/
gsutil -m -o "GSUtil:parallel_process_count=3" -o "GSUtil:parallel_thread_count=15" rsync -d -r ${BUCKET_URL}/${LATEST} /data/relay/chains/${RELAY_CHAIN_PATH}/{{ $databasePath }}/
fi
env:
- name: RELAY_CHAIN_PATH
Expand Down Expand Up @@ -336,6 +337,9 @@ spec:
{{- if or (eq .Values.node.role "authority") (eq .Values.node.role "validator") }}
--validator \
{{- end }}
{{- if .Values.node.database }}
--database={{ .Values.node.database }} \
{{- end }}
{{- if ge ( int .Values.node.pruning ) 1 }}
--unsafe-pruning \
--pruning={{ .Values.node.pruning }} \
Expand Down
1 change: 1 addition & 0 deletions charts/node/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ node:
collator:
isParachain: false
relayChain: polkadot
#database: rocksdb
# relayChainCustomChainspecUrl: ""
relayChainCustomChainspecPath: "/data/relay_chain_chainspec.json"
# relayChainDataSnapshotUrl: "https://dot-rocksdb.polkashots.io/snapshot"
Expand Down

0 comments on commit b775da1

Please sign in to comment.