Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into dailynet-submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
harryttd committed Sep 29, 2023
2 parents 210f9e0 + fea7bb4 commit 5de27e5
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 68 deletions.
16 changes: 9 additions & 7 deletions charts/tezos-faucet/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ metadata:
namespace: {{ .Release.Namespace }}
data:
config.json: |
{{- $newProfiles := dict }}
{{- range $key, $value := .Values.profiles }}
{{- $newProfiles = set $newProfiles $key (pick $value "amount" "profile") }}
{{- end }}
{{- $_ := set .Values.config.application "profiles" $newProfiles }}
{{- $_ := set .Values.config.application "disableChallenges" .Values.disableChallenges }}
{{- $_ := set .Values.config.application "minTez" .Values.minTez }}
{{- $_ := set .Values.config.application "maxTez" .Values.maxTez }}
{{ .Values.config | mustToPrettyJson | indent 4 }}
---
{{- end }}
Expand All @@ -22,11 +19,16 @@ metadata:
name: faucet-backend-config
namespace: {{ .Release.Namespace }}
data:
profiles.json: {{ .Values.profiles | mustToPrettyJson | quote }}

AUTHORIZED_HOST: "{{ .Values.authorizedHost }}"
DISABLE_CHALLENGES: "{{ .Values.disableChallenges }}"
ENABLE_CAPTCHA: "{{ .Values.enableCaptcha }}"
MAX_BALANCE: "{{ .Values.maxBalance }}"
REDIS_URL: "{{ .Values.redis.url }}"
RPC_URL: "{{ .Values.backendRpcUrl | default .Values.config.network.rpcUrl | required "An rpc url is required." }}"
MIN_TEZ: "{{ .Values.minTez }}"
MAX_TEZ: "{{ .Values.maxTez }}"
MIN_CHALLENGES: "{{ .Values.minChallenges }}"
MAX_CHALLENGES: "{{ .Values.maxChallenges }}"
MAX_CHALLENGES_WITH_CAPTCHA: "{{ .Values.maxChallengesWithCaptcha }}"
CHALLENGE_SIZE: "{{ .Values.challengeSize }}"
DIFFICULTY: "{{ .Values.difficulty }}"
21 changes: 6 additions & 15 deletions charts/tezos-faucet/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ spec:
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- image: {{ .Values.images.tezosFaucetBackend }}
name: faucet-backend
- name: faucet-backend
image: {{ .Values.images.tezosFaucetBackend }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
ports:
Expand All @@ -39,20 +40,10 @@ spec:
name: faucet-backend-config
- secretRef:
name: faucet-backend-secret
env:
# profiles.json gets set via the configmap. We store it there for easy
# access to mount as a file instead of in a new configmap. We don't
# need it to be an env var so we make it empty here.
- name: profiles.json
value: ""
volumeMounts:
- name: faucet-backend-config
mountPath: /app/dist/profiles.json
subPath: profiles.json
readOnly: true
{{- if .Values.enableUI }}
- image: {{ .Values.images.tezosFaucet }}
name: faucet
- name: faucet
image: {{ .Values.images.tezosFaucet }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
ports:
Expand Down
45 changes: 19 additions & 26 deletions charts/tezos-faucet/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Faucet frontend: https://github.com/oxheadalpha/tezos-faucet

images:
tezosFaucet: ghcr.io/oxheadalpha/tezos-faucet:latest
tezosFaucetBackend: ghcr.io/oxheadalpha/tezos-faucet-backend:latest
tezosFaucet: ghcr.io/oxheadalpha/tezos-faucet:2.1.0
tezosFaucetBackend: ghcr.io/oxheadalpha/tezos-faucet-backend:2.1.0

# Frontend app configuration. You can optionally deploy only the faucet backend.
enableUI: true
Expand All @@ -28,34 +28,26 @@ authorizedHost: "*"
backendRpcUrl: http://tezos-node-rpc:8732
# If the backend requires CAPTCHA tokens to be submitted.
enableCaptcha: true
# Faucet won't dispense to an address if its balance exceeds this.
# Faucet won't dispense to an address if its balance will exceed this.
maxBalance: 6000

# Configuration for the faucet profiles. To prevent spamming and abuse, each
# profile has specific parameters that control the distribution of Tez and the
# complexity and number of PoW challenges needed.
# - `profile`: The name of the profile.
# - `amount`: Amount of Tez to be distributed for this profile.
# - `challengesNeeded`: Number of challenges given when CAPTCHA isn't used.
# - `challengesNeededWithCaptcha`: Number of challenges given when CAPTCHA is used.
# - `difficulty`: Challenge difficulty level when CAPTCHA isn't used.
# - `difficultyWithCaptcha`: Challenge difficulty level when CAPTCHA is used.
profiles:
user:
amount: 1
challengesNeeded: 5
challengesNeededWithCaptcha: 4
difficulty: 4
difficultyWithCaptcha: 3
baker:
amount: 6000
challengesNeeded: 6
challengesNeededWithCaptcha: 5
difficulty: 5
difficultyWithCaptcha: 4
# The minimum Tez allowed per request.
minTez: 1
# The maximum Tez allowed per request.
maxTez: 6000

# Set to true to disable the requirement of solving PoW challenges.
disableChallenges: false
# Minimum number of challenges required for the minimum Tez request.
minChallenges: 1
# Maximum number of challenges required for the maximum Tez request.
maxChallenges: 550
# Maximum number of challenges required for the maximum Tez request when a
# captcha is used.
maxChallengesWithCaptcha: 66
# How many bytes the challenge string should be.
challengeSize: 2048
# Difficulty level for challenges.
difficulty: 4

# Config for the Redis backend for the PoW challenges. Redis is not needed if
# challenges are disabled.
Expand All @@ -79,6 +71,7 @@ ingress:
# hosts:
# - chart-example-frontend.local

imagePullPolicy: IfNotPresent
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
Expand Down
57 changes: 57 additions & 0 deletions snapshotEngine/snapshot-maker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,63 @@ done

if ! [ "$(kubectl get jobs "zip-and-upload-${HISTORY_MODE}" --namespace "${NAMESPACE}" -o jsonpath='{.status.conditions[?(@.type=="Complete")].status}')" != "True" ]; then
printf "%s Zip-and-upload job completed successfully.\n" "$(date "+%Y-%m-%d %H:%M:%S" "$@")"

# Delete zip-and-upload job
if kubectl get job "${ZIP_AND_UPLOAD_JOB_NAME}"; then
printf "%s Old zip-and-upload job exits. Attempting to delete.\n" "$(date "+%Y-%m-%d %H:%M:%S" "$@")"
if ! kubectl delete jobs "${ZIP_AND_UPLOAD_JOB_NAME}"; then
printf "%s Error deleting zip-and-upload job.\n" "$(date "+%Y-%m-%d %H:%M:%S" "$@")"
exit 1
fi
printf "%s Old zip-and-upload job deleted.\n" "$(date "+%Y-%m-%d %H:%M:%S" "$@")"
else
printf "%s No old zip-and-upload job detected for cleanup.\n" "$(date "+%Y-%m-%d %H:%M:%S" "$@")"
fi

# Delete old PVCs
if [ "${HISTORY_MODE}" = rolling ]; then
if [ "$(kubectl get pvc rolling-tarball-restore)" ]; then
printf "%s PVC Exists.\n" "$(date "+%Y-%m-%d %H:%M:%S" "$@")"
sleep 5
kubectl delete pvc rolling-tarball-restore
sleep 5
fi
fi

if [ "$(kubectl get pvc "${HISTORY_MODE}"-snapshot-cache-volume)" ]; then
printf "%s PVC Exists.\n" "$(date "+%Y-%m-%d %H:%M:%S" "$@")"
sleep 5
kubectl delete pvc "${HISTORY_MODE}"-snapshot-cache-volume
sleep 5
fi

if [ "$(kubectl get pvc "${HISTORY_MODE}"-snap-volume)" ]; then
printf "%s PVC Exists.\n" "$(date "+%Y-%m-%d %H:%M:%S" "$@")"
sleep 5
kubectl delete pvc "${HISTORY_MODE}"-snap-volume
sleep 5
fi

SLEEP_TIME=0m

if [ "${HISTORY_MODE}" = "archive" ]; then
SLEEP_TIME="${ARCHIVE_SLEEP_DELAY}"
if [ "${ARCHIVE_SLEEP_DELAY}" != "0m" ]; then
printf "%s artifactDelay.archive is set to %s sleeping...\n" "$(date "+%Y-%m-%d %H:%M:%S")" "${ARCHIVE_SLEEP_DELAY}"
fi
elif [ "${HISTORY_MODE}" = "rolling" ]; then
SLEEP_TIME="${ROLLING_SLEEP_DELAY}"
if [ "${ROLLING_SLEEP_DELAY}" != "0m" ]; then
printf "%s artifactDelay.rolling is set to %s sleeping...\n" "$(date "+%Y-%m-%d %H:%M:%S")" "${ROLLING_SLEEP_DELAY}"
fi
fi

if [ "${SLEEP_TIME}" = "0m" ]; then
printf "%s artifactDelay.HISTORY_MODE was not set! No delay...\n" "$(date "+%Y-%m-%d %H:%M:%S")"
fi

sleep "${SLEEP_TIME}"

fi

printf "%s Deleting temporary snapshot volume.\n" "$(date "+%Y-%m-%d %H:%M:%S" "$@")"
Expand Down
22 changes: 2 additions & 20 deletions snapshotEngine/zip-and-upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -570,24 +570,6 @@ if [[ -n "${SNAPSHOT_WEBSITE_DOMAIN_NAME}" ]]; then

# Upload chain page (index.html and assets) to root of website bucket
eval "$(set_aws_command_creds "aws")" s3 cp _site/ s3://"${SNAPSHOT_WEBSITE_DOMAIN_NAME}" --recursive | grep "*"
fi

SLEEP_TIME=0m

if [ "${HISTORY_MODE}" = "archive" ]; then
SLEEP_TIME="${ARCHIVE_SLEEP_DELAY}"
if [ "${ARCHIVE_SLEEP_DELAY}" != "0m" ]; then
printf "%s artifactDelay.archive is set to %s sleeping...\n" "$(date "+%Y-%m-%d %H:%M:%S")" "${ARCHIVE_SLEEP_DELAY}"
fi
elif [ "${HISTORY_MODE}" = "rolling" ]; then
SLEEP_TIME="${ROLLING_SLEEP_DELAY}"
if [ "${ROLLING_SLEEP_DELAY}" != "0m" ]; then
printf "%s artifactDelay.rolling is set to %s sleeping...\n" "$(date "+%Y-%m-%d %H:%M:%S")" "${ROLLING_SLEEP_DELAY}"
fi
fi

if [ "${SLEEP_TIME}" = "0m" ]; then
printf "%s artifactDelay.HISTORY_MODE was not set! No delay...\n" "$(date "+%Y-%m-%d %H:%M:%S")"
fi

sleep "${SLEEP_TIME}"
exit 0
fi

0 comments on commit 5de27e5

Please sign in to comment.