Skip to content

Add pusher chart #24

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
23 changes: 23 additions & 0 deletions charts/pusher/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
23 changes: 23 additions & 0 deletions charts/pusher/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: v2
name: pyth-pusher
description: A Helm chart for deploying Pythnet price pusher
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# 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
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
19 changes: 19 additions & 0 deletions charts/pusher/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Helm Chart - Pyth Price Pusher
this helm chart deploys the full stack components required to push cryptocurrency prices to the Pyth network. The chart supports setting up multiple chains with customized price configurations for each individual chain.

# Usage

TODO: update with pyth's usage instructions
```
helm repo add https://charts.keom.io
helm upgrade --install pyth-pusher keom/pyth-pusher --namespace pyth --create-namespace --values values.yml
```

# Notes
The resource allocations is relaxed to ensure smooth operations. Might improve in future versions

# TODO
- Move resource assignment to values.yml
- Add monitoring stack to monitor gas prices and expenses
- Alerts when pusher wallets passes a preset threshold
- Ingress option to expose price-service for dapps
71 changes: 71 additions & 0 deletions charts/pusher/templates/price_pusher.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{{- range $key, $pusher := .Values.pushers }}
apiVersion: v1
kind: ConfigMap
metadata:
name: price-pusher-config-{{ $pusher.id }}
data:
mnemonic.txt: {{- $pusher.mnemonic | toYaml | indent 2 }}
price_config.yaml: {{- $pusher.price_config | toYaml | indent 2 }}

---

apiVersion: apps/v1
kind: Deployment
metadata:
name: price-pusher-{{ $pusher.id }}
labels:
app: price-pusher-{{ $pusher.id }}
spec:
selector:
matchLabels:
app: price-pusher-{{ $pusher.id }}
replicas: 1
template:
metadata:
labels:
app: price-pusher-{{ $pusher.id }}
spec:
containers:
- name: pusher
image: public.ecr.aws/pyth-network/xc-price-pusher:v4.0.0
command:
- "npm"
- "run"
- "start"
- "--"
- "evm"
- "--endpoint"
- "{{ $pusher.rpc }}"
- "--mnemonic-file"
- "/env/mnemonic.txt"
- "--pyth-contract-address"
- "{{ $pusher.pyth_address }}"
- "--price-service-endpoint"
- "http://price-service:4200"
- "--price-config-file"
- "/env/price_config.yaml"
# - '--custom-gas-station'
# - '1101'
- "--override-gas-price-multiplier"
- "4"
- "--tx-speed"
- "standard"
- "--pushing-frequency"
- "60"
- "--polling-frequency"
- "30"

resources:
limits:
memory: "512Mi"
cpu: "512m"
volumeMounts:
- name: price-pusher-config-{{ $pusher.id }}
mountPath: /env/
volumes:
- name: price-pusher-config-{{ $pusher.id }}
configMap:
name: price-pusher-config-{{ $pusher.id }}
restartPolicy: Always
---
{{- end }}
64 changes: 64 additions & 0 deletions charts/pusher/templates/price_service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: price-service
spec:
replicas: 2
selector:
matchLabels:
app: price-service
template:
metadata:
labels:
app: price-service
spec:
containers:
- name: price-service
image: public.ecr.aws/pyth-network/xc-server:v3.0.3
resources:
limits:
memory: "1024Mi"
cpu: "512m"
ports:
- containerPort: 4200
- containerPort: 8081
env:
- name: REST_PORT
value: "4200"
- name: PROM_PORT
value: "8081"
- name: READINESS_SPY_SYNC_TIME_SECONDS
value: "20"
- name: READINESS_NUM_LOADED_SYMBOLS
value: "50"
- name: LOG_LEVEL
value: "info"
- name: SPY_SERVICE_HOST
value: spy-service:7072
- name: SPY_SERVICE_FILTERS
value: |
[
{
"chain_id": 1,
"emitter_address": "6bb14509a612f01fbbc4cffeebd4bbfb492a86df717ebe92eb6df432a3f00a25"
},
{
"chain_id": 26,
"emitter_address": "f8cd23c2ab91237730770bbea08d61005cdda0984348f3f6eecb559638c0bba0"
}
]

---
apiVersion: v1
kind: Service
metadata:
name: price-service
annotations:
prometheus.io/scrape: "true"
spec:
selector:
app: price-service
ports:
- port: 4200
targetPort: 4200

48 changes: 48 additions & 0 deletions charts/pusher/templates/spy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: spy
spec:
selector:
matchLabels:
app: spy
template:
metadata:
labels:
app: spy
spec:
containers:
- name: spy
image: ghcr.io/wormhole-foundation/guardiand:main
resources:
limits:
memory: "1024Mi"
cpu: "512m"
ports:
- containerPort: 7072
args:
- 'spy'
- '--nodeKey'
- '/node.key'
- '--spyRPC'
- ':7072'
- '--bootstrap'
- '/dns4/wormhole-mainnet-v2-bootstrap.certus.one/udp/8999/quic/p2p/12D3KooWQp644DK27fd3d4Km3jr7gHiuJJ5ZGmy8hH4py7fP4FP7'
- '--network'
- '/wormhole/mainnet/2'
- '--logLevel'
- 'info'

---
apiVersion: v1
kind: Service
metadata:
name: spy-service
annotations:
prometheus.io/scrape: "true"
spec:
selector:
app: spy
ports:
- port: 7072
targetPort: 7072
52 changes: 52 additions & 0 deletions charts/pusher/templates/spy_restarter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Restart SPY every 1h to avoid stalls.
kind: ServiceAccount
apiVersion: v1
metadata:
name: deployment-restart
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: deployment-restart
rules:
- apiGroups: ["apps", "extensions"]
resources: ["deployments"]
resourceNames: ["spy"]
verbs: ["get", "patch", "list", "watch"]
---
# bind the role to the service account
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: deployment-restart
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: deployment-restart
subjects:
- kind: ServiceAccount
name: deployment-restart
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: deployment-restart-job
spec:
concurrencyPolicy: Forbid
schedule: '59 * * * *' # every hour at *:59
jobTemplate:
spec:
backoffLimit: 2
activeDeadlineSeconds: 600
template:
spec:
serviceAccountName: deployment-restart
restartPolicy: Never
containers:
- name: kubectl
image: bitnami/kubectl
command:
- 'kubectl'
- 'rollout'
- 'restart'
- 'deployment/spy'
67 changes: 67 additions & 0 deletions charts/pusher/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# you can setup multiple pushers for different chains
# Each pusher runs on it's own Deployment/Pod
pushers:
- id: manta-pacific
name: Manta Pusher
rpc: https://pacific-rpc.manta.network/http
pyth_address: 0xA2aa501b19aff244D90cc15a4Cf739D2725B5729
push_frequency: 60 #seconds
poll_frequency: 30 #seconds
gas_price_multiplier: 4 #4x
mnemonic: |-
INSERT THE WALLET MNEMONIC
price_config: |-
- alias: ETH/USD
id: ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace
time_difference: 3600
price_deviation: 0.5
confidence_ratio: 1
- alias: USDC/USD
id: eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a
time_difference: 8600
price_deviation: 0.5
confidence_ratio: 1
- alias: USDT/USD
id: 2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b
time_difference: 8600
price_deviation: 0.5
confidence_ratio: 1


- id: polygonzkevm
name: POS Pusher
rpc: https://zkevm-rpc.com
pyth_address: 0xC5E56d6b40F3e3B5fbfa266bCd35C37426537c65
push_frequency: 60 #seconds
poll_frequency: 30 #seconds
gas_price_multiplier: 4 #4x
# mnemonic for the wallet that will push price updates
mnemonic: |-
INSERT WALLET MNEMONIC
price_config: |-
- alias: WETH/USD
id: ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace
time_difference: 3600
price_deviation: 0.5
confidence_ratio: 1
- alias: USDC/USD
id: eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a
time_difference: 3600
price_deviation: 0.5
confidence_ratio: 1
- alias: USDT/USD
id: 2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b
time_difference: 3600
price_deviation: 0.5
confidence_ratio: 1
- alias: MATIC/USD
id: 5de33a9112c2b700b8d30b8a3402c103578ccfa2765696471cc672bd5cf6ac52
time_difference: 3600
price_deviation: 0.5
confidence_ratio: 1
- alias: BTC/USD
id: '0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43'
time_difference: 3600
price_deviation: 0.5
confidence_ratio: 1