Skip to content

Commit

Permalink
Merge pull request #507 from willcl-ark/fork-observer-v2
Browse files Browse the repository at this point in the history
add forkobserver
  • Loading branch information
m3dwards authored Sep 4, 2024
2 parents f6712a6 + fee6e0d commit 8b7782f
Show file tree
Hide file tree
Showing 20 changed files with 552 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ jobs:
- dag_connection_test.py
- logging_test.py
- rpc_test.py
- services_test.py
- scenarios_test.py
steps:
- uses: actions/checkout@v4
Expand Down
10 changes: 10 additions & 0 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,13 @@ warnet quickstart
```

This will check you have the required dependencies and guide you through setting up and deploying your first network.

## fork-observer

If you enabled [fork-observer](https://github.com/0xB10C/fork-observer), you must forward the port from the cluster to your local machine:

```bash
kubectl port-forward fork-observer 2323
```

And then the GUI can be accessed via `localhost:2323` in a web browser.
3 changes: 2 additions & 1 deletion resources/charts/bitcoincore/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ regtestConfig: |
rpcport=18443
rpcallowip=0.0.0.0/0
rpcbind=0.0.0.0
rest=1
baseConfig: |
checkmempool=0
Expand All @@ -134,4 +135,4 @@ baseConfig: |
config: ""

connect: []
connect: []
23 changes: 23 additions & 0 deletions resources/charts/fork-observer/.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/
24 changes: 24 additions & 0 deletions resources/charts/fork-observer/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: fork-observer
description: A Helm chart for fork-observer

# 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: 0.1.0
1 change: 1 addition & 0 deletions resources/charts/fork-observer/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fork-observer is watching you
57 changes: 57 additions & 0 deletions resources/charts/fork-observer/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "fork-observer.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "fork-observer.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s" .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "fork-observer.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "fork-observer.labels" -}}
helm.sh/chart: {{ include "fork-observer.chart" . }}
{{ include "fork-observer.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "fork-observer.selectorLabels" -}}
app.kubernetes.io/name: {{ include "fork-observer.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "fork-observer.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "fork-observer.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
11 changes: 11 additions & 0 deletions resources/charts/fork-observer/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "fork-observer.fullname" . }}
labels:
{{- include "fork-observer.labels" . | nindent 4 }}
data:
config.toml: |
{{- .Values.configQueryInterval | nindent 4 }}
{{- tpl .Values.baseConfig . | nindent 4 }}
{{- .Values.config | nindent 8 }}
48 changes: 48 additions & 0 deletions resources/charts/fork-observer/templates/pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
apiVersion: v1
kind: Pod
metadata:
name: {{ include "fork-observer.fullname" . }}
labels:
{{- include "fork-observer.labels" . | nindent 4 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
app: {{ include "fork-observer.fullname" . }}
spec:
restartPolicy: "{{ .Values.restartPolicy }}"
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 4 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 4 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 8 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: web
containerPort: {{ .Values.port }}
protocol: TCP
livenessProbe:
{{- toYaml .Values.livenessProbe | nindent 8 }}
readinessProbe:
{{- toYaml .Values.readinessProbe | nindent 8 }}
resources:
{{- toYaml .Values.resources | nindent 8 }}
volumeMounts:
{{- with .Values.volumeMounts }}
{{- toYaml . | nindent 8 }}
{{- end }}
- mountPath: /app/config.toml
name: config
subPath: config.toml
volumes:
{{- with .Values.volumes }}
{{- toYaml . | nindent 4 }}
{{- end }}
- configMap:
name: {{ include "fork-observer.fullname" . }}
name: config
16 changes: 16 additions & 0 deletions resources/charts/fork-observer/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "fork-observer.fullname" . }}
labels:
{{- include "fork-observer.labels" . | nindent 4 }}
app: {{ include "fork-observer.fullname" . }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.port }}
targetPort: web
protocol: TCP
name: rpc
selector:
{{- include "fork-observer.selectorLabels" . | nindent 4 }}
115 changes: 115 additions & 0 deletions resources/charts/fork-observer/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Default values for fork-observer.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
namespace: warnet

restartPolicy: Always

image:
repository: b10c/fork-observer
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "latest"

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

podLabels:
app: "warnet"
mission: "observer"

podSecurityContext: {}
# fsGroup: 2000

securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000

service:
type: ClusterIP

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi

livenessProbe:
exec:
command:
- pidof
- fork-observer
failureThreshold: 3
initialDelaySeconds: 5
periodSeconds: 5
successThreshold: 1
timeoutSeconds: 1
readinessProbe:
failureThreshold: 1
periodSeconds: 1
successThreshold: 1
tcpSocket:
port: 2323
timeoutSeconds: 1

# Additional volumes on the output Deployment definition.
volumes: []
# - name: foo
# secret:
# secretName: mysecret
# optional: false

# Additional volumeMounts on the output Deployment definition.
volumeMounts: []
# - name: foo
# mountPath: "/etc/foo"
# readOnly: true

port: 2323

configQueryInterval: |
# Interval for checking for new blocks
query_interval = 20
maxInterestingHeights: 100

baseConfig: |
# Database path of the key value store. Will be created if non-existing.
database_path = "db"
# path to the location of the static www files
www_path = "./www"
# Webserver listen address
address = "0.0.0.0:2323"
# Custom footer for the site.
footer_html = """
<div class="my-2">
<div>
<span class="text-muted">Warnet fork-observer</span>
</div>
</div>
"""
[[networks]]
id = 0xDEADBE
name = "Warnet"
description = "A Warnet"
min_fork_height = 0
max_interesting_heights = {{ .Values.maxInterestingHeights }}
[pool_identification]
enable = false
config: ""
4 changes: 3 additions & 1 deletion resources/networks/6_node_bitcoin/network.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ nodes:
- name: tank-0005
connect:
- tank-0006
- name: tank-0006
- name: tank-0006
fork_observer:
enabled: false
2 changes: 1 addition & 1 deletion resources/networks/6_node_bitcoin/node-defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ image:

config: |
dns=1
debug=rpc
debug=rpc
29 changes: 29 additions & 0 deletions resources/networks/node-defaults.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
chain: regtest

collectLogs: true
metricsExport: false

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi

image:
repository: bitcoindevproject/bitcoin
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "27.0"

config: |
dns=1
debug=rpc
rpcauth=forkobserver:1418183465eecbd407010cf60811c6a0$d4e5f0647a63429c218da1302d7f19fe627302aeb0a71a74de55346a25d8057c
rpcwhitelist=forkobserver:getchaintips,getblockheader,getblockhash,getblock,getnetworkinfo
rpcwhitelistdefault=0
Loading

0 comments on commit 8b7782f

Please sign in to comment.