Skip to content

Commit

Permalink
feat(provider): implement blacklist
Browse files Browse the repository at this point in the history
  • Loading branch information
andy108369 committed Nov 2, 2024
1 parent 10b74c5 commit d7e8c34
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion charts/akash-provider/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type: application
# Versions are expected to follow Semantic Versioning (https://semver.org/)

# Major version bit highlights the mainnet release (e.g. mainnet4 = 4.x.x, mainnet5 = 5.x.x, ...)
version: 11.1.0
version: 11.1.1

# 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
Expand Down
15 changes: 14 additions & 1 deletion charts/akash-provider/scripts/price_script_generic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# WARNING: the runtime of this script should NOT exceed 5 seconds! (Perhaps can be amended via AKASH_BID_PRICE_SCRIPT_PROCESS_TIMEOUT env variable)
# Requirements:
# curl jq bc mawk ca-certificates
# Version: April-03-2024
# Version: Nov-02-2024
set -o pipefail

# Example:
Expand All @@ -28,6 +28,19 @@ if ! [[ -z $WHITELIST_URL ]]; then
fi
fi

# Do not bid if the tenant address is in the list passed with BLACKLIST_URL environment variable
if ! [[ -z $BLACKLIST_URL ]]; then
BLACKLIST=/tmp/price-script.blacklist
if ! test $(find $BLACKLIST -mmin -10 2>/dev/null); then
curl -o $BLACKLIST -s --connect-timeout 3 --max-time 3 -- $BLACKLIST_URL
fi

if grep -qw "$AKASH_OWNER" $BLACKLIST; then
echo -n "$AKASH_OWNER is blacklisted" >&2
exit 1
fi
fi

function get_akt_price {
# cache AKT price for 60 minutes to reduce the API pressure as well as to slightly accelerate the bidding (+5s)
CACHE_FILE=/tmp/aktprice.cache
Expand Down
4 changes: 4 additions & 0 deletions charts/akash-provider/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ spec:
- name: WHITELIST_URL
value: "{{ .Values.whitelist_url }}"
{{- end }}
{{ if .Values.blacklist_url }}
- name: BLACKLIST_URL
value: "{{ .Values.blacklist_url }}"
{{- end }}
{{ if .Values.debug_bid_script }}
- name: DEBUG_BID_SCRIPT
value: "{{ .Values.debug_bid_script }}"
Expand Down

0 comments on commit d7e8c34

Please sign in to comment.