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

BCD indexer updates #537

Merged
merged 44 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
42a174d
add Nomadic's and BCD tezos indexers
nicolasochem Mar 24, 2021
0e5dbc8
Merge branch 'master' into indexer_new
nicolasochem Mar 25, 2021
9ff649e
restore to upstream version of bcd in anticipation for the release
nicolasochem Mar 25, 2021
7ea5e98
Merge branch 'master' into indexer_new
nicolasochem Mar 25, 2021
c1b17c5
remove dep for now
nicolasochem Mar 25, 2021
3910c59
bump bcdhub version
nicolasochem Mar 25, 2021
8181980
make storage size parametrizable
nicolasochem Mar 25, 2021
c8d25de
Merge branch 'size_param' into indexer_new
nicolasochem Mar 25, 2021
c60057d
hardcode space requirements for indexing mainnet for now
nicolasochem Mar 25, 2021
2e8697e
postgres does not want data folder to be an entire mount point:
nicolasochem Mar 26, 2021
eee2ac1
after last bcd release, it's no longer needed to rebuild
nicolasochem Apr 1, 2021
d243424
Merge branch 'master' into indexer_new
nicolasochem Apr 6, 2021
9ce5ebc
templatize and remove hardcoding
nicolasochem Apr 6, 2021
14e0491
hardcode v9.0-rc1 for edo2
nicolasochem Apr 6, 2021
15d255b
name rpc port
nicolasochem Apr 8, 2021
4053ca5
target node for rpc service
nicolasochem Apr 8, 2021
29a2013
set uid/gid to 1000 to make elastic work on eks
nicolasochem Apr 9, 2021
56989c5
fix rabbit perm issue on eks
nicolasochem Apr 9, 2021
02a4bb3
bump bcd to latest version 3.5.2
nicolasochem Apr 9, 2021
f2723a6
Revert "bump bcd to latest version 3.5.2"
nicolasochem Apr 9, 2021
bd1c8cf
Make serviceName of indexer yamls empty str
harryttd Apr 9, 2021
5643fe3
Don't create statefulsets and headless svc if replicas = 0
harryttd Apr 9, 2021
a0b8984
Merge pull request #2 from tqtezos/indexer-updates
nicolasochem Apr 13, 2021
1dda418
Expose bcd api port
harryttd Apr 20, 2021
d85ebf9
Add bcd metrics container to indexer pod
harryttd Apr 20, 2021
3a7a7b2
Create a shared volume used by some bcd indexer containers
harryttd Apr 20, 2021
fe9b4f8
Remove unused configmap
harryttd Apr 20, 2021
6994b50
Change naming of indexer props in values.yaml
harryttd Apr 20, 2021
cca2e0b
Make default indexer bcd
harryttd Apr 22, 2021
6ef7354
Remove appType label from indexer statefulsets
harryttd Apr 20, 2021
c8420ac
Make rpc service select on appType=tezos-node
harryttd Apr 20, 2021
c38bc06
Add imagePullPolicy=IfNotPresent to some containers
harryttd Apr 22, 2021
02c674e
Update template functions that determine which indexer to deploy
harryttd Apr 22, 2021
2fc5ff8
Add bcd service
harryttd Apr 22, 2021
7789681
Merge branch 'master' into bcd-indexer-updates
harryttd Sep 2, 2022
8011889
Delete nomadic indexer
harryttd Sep 2, 2022
8234a41
Update bcd indexer
harryttd Oct 9, 2022
ec990f4
Merge branch 'master' into bcd-indexer-updates
harryttd Oct 9, 2022
0f15bf9
Add storageClassName field
harryttd Oct 9, 2022
0f74078
Merge branch 'master' into bcd-indexer-updates
harryttd Nov 16, 2022
e4029c5
Merge branch 'master' into bcd-indexer-updates
harryttd Feb 1, 2023
fb987b1
Make bcd images configurable
harryttd Feb 1, 2023
f5ff84c
black .
harryttd Feb 1, 2023
bf640b4
Update BCD indexer to 4.4.0
harryttd Feb 1, 2023
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
24 changes: 14 additions & 10 deletions charts/pyrometer/scripts/pyrometer_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
import datetime

import logging
log = logging.getLogger('werkzeug')

log = logging.getLogger("werkzeug")
log.setLevel(logging.ERROR)

application = Flask(__name__)

unhealthy_bakers = set()

@application.route('/pyrometer_webhook', methods=['POST'])

@application.route("/pyrometer_webhook", methods=["POST"])
def pyrometer_webhook():
'''
"""
Receive all events from pyrometer
'''
"""
for msg in request.get_json():
if msg["kind"] == "baker_unhealthy":
print(f"Baker {msg['baker']} is unhealthy")
Expand All @@ -26,14 +28,16 @@ def pyrometer_webhook():

return "Webhook received"

@application.route('/metrics', methods=['GET'])

@application.route("/metrics", methods=["GET"])
def prometheus_metrics():
'''
"""
Prometheus endpoint
'''
return f'''# total number of monitored bakers that are currently unhealthy
"""
return f"""# total number of monitored bakers that are currently unhealthy
pyrometer_unhealthy_bakers_total {len(unhealthy_bakers)}
'''
"""


if __name__ == "__main__":
application.run(host = "0.0.0.0", port = 31732, debug = False)
application.run(host="0.0.0.0", port=31732, debug=False)
6 changes: 0 additions & 6 deletions charts/tezos/Chart.lock

This file was deleted.

27 changes: 19 additions & 8 deletions charts/tezos/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,21 @@ metadata:
{{- end }}
{{- end }}

{{/*
Has per-block votes defined?
*/}}
{{- define "tezos.hasPerBlockVotes" }}
{{- range .Values.protocols }}
{{- if .vote }}
{{- "true" }}
{{- end }}
{{- end }}
{{- end }}

harryttd marked this conversation as resolved.
Show resolved Hide resolved
{{/*
Should deploy TZKT indexer?
*/}}
{{- define "tezos.shouldDeployTzktIndexer" -}}

{{- $indexers := .Values.indexers | default dict }}
{{- if $indexers.tzkt }}
{{- $tzkt_config := $indexers.tzkt.config | default dict }}
Expand All @@ -126,16 +136,17 @@ metadata:
{{- "" }}
{{- end }}
{{- end }}

{{- end }}

{{/*
Has per-block votes defined?
Checks if `bcdIndexer` has `rpcUrl` and `dbPassword` set.
Returns the true type or empty string which is falsey.
*/}}
{{- define "tezos.hasPerBlockVotes" }}
{{- range .Values.protocols }}
{{- if .vote }}
{{- "true" }}
{{- end }}
{{- define "tezos.shouldDeployBcdIndexer" -}}
{{- $indexConfig := .Values.bcdIndexer | default dict }}
{{- if and $indexConfig.indexerRpcUrl $indexConfig.dbPassword }}
{{- "true" }}
{{- else }}
{{- "" }}
{{- end }}
{{- end }}
96 changes: 96 additions & 0 deletions charts/tezos/templates/bcd_indexer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{{- if (include "tezos.shouldDeployBcdIndexer" .) }}

apiVersion: v1
kind: Service
metadata:
name: bcd
namespace: {{ .Release.Namespace }}
spec:
ports:
- port: 14000
name: bcd
targetPort: bcd
selector:
app: {{ .Values.bcd_indexer_statefulset.name }}
type: NodePort

---
apiVersion: v1
kind: ConfigMap
metadata:
name: bcd-env
namespace: {{ .Release.Namespace }}
data:
BCD_ENV: sandbox
GIN_MODE: debug
DB_HOSTNAME: localhost
SANDBOX_NODE_URI: {{ .Values.bcdIndexer.indexerRpcUrl }}

---
apiVersion: v1
kind: Secret
metadata:
name: db-creds
namespace: {{ .Release.Namespace }}
data:
POSTGRES_USER: {{ b64enc .Values.bcdIndexer.dbUser }}
POSTGRES_PASSWORD: {{ b64enc .Values.bcdIndexer.dbPassword }}
POSTGRES_DB: {{ b64enc .Values.bcdIndexer.dbName }}
PGDATA: {{ b64enc "/var/lib/postgresql/data/pgdata" }}

---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ .Values.bcd_indexer_statefulset.name }}
namespace: {{ .Release.Namespace }}
spec:
podManagementPolicy: Parallel
selector:
matchLabels:
app: {{ .Values.bcd_indexer_statefulset.name }}
serviceName: ""
template:
metadata:
labels:
app: {{ .Values.bcd_indexer_statefulset.name }}
spec:
containers:
- image: {{ .Values.bcdIndexer.images.api }}
name: api
ports:
- containerPort: 14000
name: bcd
envFrom:
- configMapRef:
name: bcd-env
- secretRef:
name: db-creds
- image: {{ .Values.bcdIndexer.images.indexer }}
name: indexer
envFrom:
- configMapRef:
name: bcd-env
- secretRef:
name: db-creds
- image: postgres:14
name: db
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: indexer-db
envFrom:
- secretRef:
name: db-creds
volumeClaimTemplates:
- metadata:
name: indexer-db
spec:
accessModes:
- ReadWriteOnce
storageClassName: {{ .Values.bcdIndexer.storageClassName }}
resources:
requests:
storage: "300Gi"

{{- end }}
19 changes: 16 additions & 3 deletions charts/tezos/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ tezos_k8s_images:
## scripts that will look up some of these values. They should not be modified.
tzkt_indexer_statefulset:
name: tzkt-indexer
bcd_indexer_statefulset:
name: bcd-indexer
signer_statefulset:
name: tezos-signer
pod_type: signing
Expand Down Expand Up @@ -264,7 +266,7 @@ serviceMonitor:
#
# By default no signer is configured:
signers: {}
# Here is an example of octez signer config. When set, the
# Here is an example of octez signer config. When set, the
# ```
# signers:
# tezos-signer-0:
Expand Down Expand Up @@ -449,8 +451,8 @@ protocols:
## Deploy an indexer with the chain. An indexer puts the chain
## contents in a database for efficient indexing. Most dapps need it.
## Supported indexers:
## * tzkt https://github.com/baking-bad/tzkt
#
## * tzkt: https://github.com/baking-bad/tzkt
## * bcd: https://github.com/baking-bad/bcdhub
## Templatized indexer configuration values go in the config field.
##
# indexers:
Expand Down Expand Up @@ -489,3 +491,14 @@ protocols:
# db_password: bar
# # api_log_level: Debug
# # indexer_log_level: Debug

bcdIndexer:
images:
api: ghcr.io/baking-bad/bcdhub-api:4.4.0
indexer: ghcr.io/baking-bad/bcdhub-indexer:4.4.0
# dbName: bcd
# dbPassword: bcd-password
# dbUser: bcd
# storageClassName: ""
# indexerRpcUrl: http://archive-baking-node-0.archive-baking-node:8732

1 change: 1 addition & 0 deletions mkchain/tqchain/mkchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def quoted_scalar(dumper, data): # a representer to force quotations on scalars
},
}


# python versions < 3.8 doesn't have "extend" action
class ExtendAction(argparse.Action):
def __call__(self, parser, namespace, values, option_string=None):
Expand Down
30 changes: 16 additions & 14 deletions snapshotEngine/getAllSnapshotMetadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import urllib, json
import urllib.request

allSubDomains = os.environ['ALL_SUBDOMAINS'].split(",")
snapshotWebsiteBaseDomain = os.environ['SNAPSHOT_WEBSITE_DOMAIN_NAME']
allSubDomains = os.environ["ALL_SUBDOMAINS"].split(",")
snapshotWebsiteBaseDomain = os.environ["SNAPSHOT_WEBSITE_DOMAIN_NAME"]

filename="tezos-snapshots.json"
filename = "tezos-snapshots.json"

# Write empty top-level array to initialize json
json_object = []
Expand All @@ -15,16 +15,18 @@

# Get each subdomain's base.json and combine all artifacts into 1 metadata file
for subDomain in allSubDomains:
baseJsonUrl="https://"+subDomain+"."+snapshotWebsiteBaseDomain+"/base.json"
try:
with urllib.request.urlopen(baseJsonUrl) as url:
data = json.loads(url.read().decode())
for entry in data:
json_object.append(entry)
except urllib.error.HTTPError:
continue
baseJsonUrl = (
"https://" + subDomain + "." + snapshotWebsiteBaseDomain + "/base.json"
)
try:
with urllib.request.urlopen(baseJsonUrl) as url:
data = json.loads(url.read().decode())
for entry in data:
json_object.append(entry)
except urllib.error.HTTPError:
continue

# Write to file
with open (filename, 'w') as json_file:
json_string = json.dumps(json_object, indent=4)
json_file.write(json_string)
with open(filename, "w") as json_file:
json_string = json.dumps(json_object, indent=4)
json_file.write(json_string)
Loading