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

[bsc] add prune-block init #192

Merged
merged 1 commit into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dysnix/bsc/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: bsc
description: Binance Smart Chain chart for Kubernetes
version: "0.6.9"
version: "0.6.10"
appVersion: "v1.1.8"

keywords:
Expand Down
2 changes: 2 additions & 0 deletions dysnix/bsc/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ data:
{{- include (print $.Template.BasePath "/scripts/_gcs_cleanup.tpl") . | nindent 4 }}
prune.sh: |-
{{- include (print $.Template.BasePath "/scripts/_prune.tpl") . | nindent 4 }}
prune_block.sh: |-
{{- include (print $.Template.BasePath "/scripts/_prune_block.tpl") . | nindent 4 }}
cron.sh: |-
{{- include (print $.Template.BasePath "/scripts/_cron.tpl") . | nindent 4 }}
update-pod-deletion-cost.sh: |-
Expand Down
28 changes: 28 additions & 0 deletions dysnix/bsc/templates/scripts/_prune_block.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env sh

# script performs BSC block prune from ancientDB, removing [unneeded in some cases] historical blocks
# good use case is a bootnode w/o RPC
# block prune should speed up node in runtime as well as allow to use less disk space
# after block prune the node will not be able to serve RPC on pruned blocks
# Around last 90000 blocks are kept in the node state before moving on to ancientDB

set -x

DATA_DIR="{{ .Values.bsc.base_path }}"

GETH=/usr/local/bin/geth
# how much recent blocks do we need to keep. Default 0 means we clean up ancientDB completely
BLOCKS_RESERVED=${1:-0}

ret=0
# background logging
tail -F "${DATA_DIR}/bsc.log" &
# prune-block will turn our full node into light one actually
$GETH --config=/config/config.toml --datadir=${DATA_DIR} --datadir.ancient=${DATA_DIR}/geth/chaindata/ancient --cache {{ .Values.bsc.cache }} snapshot prune-block --block-amount-reserved=${BLOCKS_RESERVED}
ret=$?
if [ "${ret}" -eq "0" ];then
# update timestamp
date +%s > "${DATA_DIR}/block_prune_timestamp"
fi

exit $ret
15 changes: 15 additions & 0 deletions dysnix/bsc/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,21 @@ spec:
- name: generated-bsc-config
mountPath: /config
{{- end }}
{{- if .Values.bsc.pruneBlock.enabled }}
- name: bsc-prune-block
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- /scripts/prune_block.sh
volumeMounts:
- name: bsc-pvc
mountPath: {{ .Values.bsc.base_path }}
- name: scripts
mountPath: /scripts
- name: generated-bsc-config
mountPath: /config
{{- end }}
volumes:
- name: bsc-config
configMap:
Expand Down
2 changes: 2 additions & 0 deletions dysnix/bsc/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ bsc:
baseUrl: "bucket/path/to/dir"
prune:
enabled: false
pruneBlock:
enabled: false
forceInitFromSnapshot: false
snapshotUrl:
snapshotRsyncUrl: "rsync://192.168.8.4/snapshot/geth/node/geth"
Expand Down