Skip to content
Merged
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
7 changes: 5 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
runs-on: ubuntu-latest
needs: test-multiple-go-versions
# Until we have developer environments, we don't need the images built on other that main branches.
if: github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'push-image')
if: github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'push-image') || contains(github.event.pull_request.labels.*.name, 'e2e-devnet-test')
strategy:
matrix:
# Build dev & prod images
Expand All @@ -117,6 +117,8 @@ jobs:
- name: Docker Metadata action
id: meta
uses: docker/metadata-action@v4
env:
DOCKER_METADATA_PR_HEAD_SHA: "true"
with:
images: |
ghcr.io/pokt-network/pocket-v1
Expand All @@ -128,6 +130,7 @@ jobs:
type=ref,event=branch${{ matrix.imageType == 'dev' && ',suffix=-dev' || '' }}
type=ref,event=pr${{ matrix.imageType == 'dev' && ',suffix=-dev' || '' }}
type=sha${{ matrix.imageType == 'dev' && ',suffix=-dev' || '' }}
type=sha,format=long${{ matrix.imageType == 'dev' && ',suffix=-dev' || '' }}
type=raw,value=latest,enable={{is_default_branch}}${{ matrix.imageType == 'dev' && ',suffix=-dev' || '' }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
Expand All @@ -142,7 +145,7 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# NB: Uncomment below if arm64 build is needed; arm64 builds are off by default because build times are significant.
platforms: linux/amd64 #,linux/arm64
platforms: linux/amd64 #,linux/arm64
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just remove arm?

file: build/Dockerfile.${{ matrix.osType }}.${{ matrix.imageType }}
cache-from: type=gha
cache-to: type=gha,mode=max
Expand Down
5 changes: 5 additions & 0 deletions build/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.0.0.36] - 2023-04-19

- Changed validator DNS names to match new naming convention (again, helm chart was renamed)
- Changed the way `cluster-manager` looks up the new validators to be staked.

## [0.0.0.35] - 2023-04-17

- Removed runtime/configs.Config#UseLibp2p field
Expand Down
2 changes: 1 addition & 1 deletion build/localnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ For example:

Configurations can be changed in helm charts where network protocol actor configs are maintained. You can find them in [this directory](../../charts).

`config.json` file is created using the `config` section content in`values.yaml`. For example, you can find the configuration for a validator [here](../../charts/pocket-validator/values.yaml#70).
`config.json` file is created using the `config` section content in `values.yaml`. For example, you can find the configuration for a validator [here](../../charts/pocket/values.yaml#70).

If you need to add a new parameter – feel free to modify the section in place. Some of the parameters that contain secrets (e.g. private key), are stored in Secrets object and injected as environment variables.

Expand Down
5 changes: 3 additions & 2 deletions build/localnet/Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,16 @@ k8s_resource('pocket-v1-cli-client', labels=['client'])
k8s_yaml(['manifests/cluster-manager.yaml'])
k8s_resource('pocket-v1-cluster-manager', labels=['cluster-manager'])

check_helm_dependencies_for_chart(root_dir + "/charts/pocket-validator")
check_helm_dependencies_for_chart(root_dir + "/charts/pocket")
for x in range(localnet_config["validators"]["count"]):
validator_number = x + 1
formatted_validator_number = local('printf "%03d" ' + str(validator_number))

k8s_yaml(helm(root_dir + "/charts/pocket-validator",
k8s_yaml(helm(root_dir + "/charts/pocket",
name="validator-%s" % formatted_validator_number,
namespace="default",
set=[
"global.postgresql.auth.postgresPassword=LocalNetPassword",
"image.repository=validator-image",
"privateKeySecretKeyRef.name=v1-localnet-validators-private-keys",
"privateKeySecretKeyRef.key=%s" % formatted_validator_number,
Expand Down
5 changes: 3 additions & 2 deletions build/localnet/cluster-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
)

const cliPath = "/usr/local/bin/client"
const validatorServiceUrlFormat = "validator-%s-pocket:%d"

var (
rpcURL string
Expand All @@ -33,7 +34,7 @@ var (
)

func init() {
rpcURL = fmt.Sprintf("http://%s:%s", runtime.GetEnv("RPC_HOST", "v1-validator001"), defaults.DefaultRPCPort)
rpcURL = fmt.Sprintf("http://%s:%s", runtime.GetEnv("RPC_HOST", defaults.Validator1EndpointK8S), defaults.DefaultRPCPort)
}

func main() {
Expand Down Expand Up @@ -77,7 +78,7 @@ func main() {
continue
}

validatorServiceUrl := fmt.Sprintf("v1-validator%s:%d", validatorId, defaults.DefaultP2PPort)
validatorServiceUrl := fmt.Sprintf(validatorServiceUrlFormat, validatorId, defaults.DefaultP2PPort)
if err := stakeValidator(privateKey, autoStakeAmount, autoStakeChains, validatorServiceUrl); err != nil {
logger.Err(err).Msg("Error staking validator")
}
Expand Down
11 changes: 7 additions & 4 deletions build/localnet/cluster-manager/utils.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
package main

import (
"regexp"

cryptoPocket "github.com/pokt-network/pocket/shared/crypto"
v1 "k8s.io/api/core/v1"
)

func isValidator(service *v1.Service) bool {
return service.Labels["v1-purpose"] == "validator"
return service.Labels["pokt.network/purpose"] == "validator"
}

// extractValidatorId extracts the validator id from the validator name (e.g. v1-validator001 -> 001)
// extractValidatorId extracts the validator id from the validator name (e.g. validator-001-pocket -> 001)
//
// it follows the pattern defined in the v1-validator template (/build/localnet/templates/v1-validator-template.yaml.tpl)
// it follows the pattern defined in the pocket helm chart.
func extractValidatorId(validatorName string) string {
if len(validatorName) >= 3 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move 3 into a constant and explain where the magic number came from.

return validatorName[len(validatorName)-3:]
re := regexp.MustCompile(`validator-(\d+)-pocket`)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good candidate to put in an init

return re.FindStringSubmatch(validatorName)[1]
}
return validatorName
}
Expand Down
6 changes: 3 additions & 3 deletions build/localnet/manifests/cli-client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ spec:
spec:
serviceAccountName: debug-client-account
initContainers:
- name: wait-for-validator-001-pocket-validator
- name: wait-for-validator-001-pocket
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to have GetSession implemented soon, which means that we're going to be able to have a "dispatch node".

  1. Do you think this would enable us to have a dispatch node rather than using validator001 for everything?
  2. If so, @okdas, can you create a ticket for it?

image: busybox
command:
[
"sh",
"-c",
'until wget -q -O - "http://validator-001-pocket-validator:50832/v1/health" --timeout=2 --tries=2 --spider >/dev/null 2>&1; do echo waiting for validator-001-pocket-validator to be online and healthy...; sleep 2; done;',
'until wget -q -O - "http://validator-001-pocket:50832/v1/health" --timeout=2 --tries=2 --spider >/dev/null 2>&1; do echo waiting for validator-001-pocket to be online and healthy...; sleep 2; done;',
]
containers:
- name: pocket
Expand Down Expand Up @@ -91,7 +91,7 @@ spec:
volumes:
- name: config-volume
configMap:
name: validator-001-pocket-validator-config
name: validator-001-pocket-config
defaultMode: 420
- name: genesis-volume
configMap:
Expand Down
4 changes: 2 additions & 2 deletions build/localnet/manifests/cluster-manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ metadata:
name: pocket-v1-cluster-manager
spec:
initContainers:
- name: wait-for-validator-001-pocket-validator
- name: wait-for-validator-001-pocket
image: busybox
command:
[
"sh",
"-c",
'until wget -q -O - "http://validator-001-pocket-validator:50832/v1/health" --timeout=2 --tries=2 --spider >/dev/null 2>&1; do echo waiting for validator-001-pocket-validator to be online and healthy...; sleep 2; done;',
'until wget -q -O - "http://validator-001-pocket:50832/v1/health" --timeout=2 --tries=2 --spider >/dev/null 2>&1; do echo waiting for validator-001-pocket to be online and healthy...; sleep 2; done;',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto, I think a ticket for s/validator-001/disaptch-node for everything in the infra would be appropriate. Thouhgts?

Copy link
Contributor Author

@okdas okdas Apr 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Olshansk would dispatch node be just another validator in that case? Just a node that is not staked as validator?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be a full node, not necessarily a validator.

]
containers:
- name: cluster-manager
Expand Down
12 changes: 6 additions & 6 deletions build/localnet/manifests/configs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4044,7 +4044,7 @@ data:
"address": "00104055c00bed7c983a48aac7dc6335d7c607a7",
"public_key": "dfe357de55649e6d2ce889acf15eb77e94ab3c5756fe46d3c7538d37f27f115e",
"chains": null,
"service_url": "validator-001-pocket-validator:42069",
"service_url": "validator-001-pocket:42069",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand All @@ -4055,7 +4055,7 @@ data:
"address": "00204737d2a165ebe4be3a7d5b0af905b0ea91d8",
"public_key": "eb2c78364525a210d994a83e02d18b4287ab81f6670cf4510ab6c9f51e296d91",
"chains": null,
"service_url": "validator-002-pocket-validator:42069",
"service_url": "validator-002-pocket:42069",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand All @@ -4066,7 +4066,7 @@ data:
"address": "00304d0101847b37fd62e7bebfbdddecdbb7133e",
"public_key": "1041a9c76539791fef9bee5b4fcd5bf4a1a489e0790c44cbdfa776b901e13b50",
"chains": null,
"service_url": "validator-003-pocket-validator:42069",
"service_url": "validator-003-pocket:42069",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand All @@ -4077,7 +4077,7 @@ data:
"address": "00404a570febd061274f72b50d0a37f611dfe339",
"public_key": "d6cea8706f6ee6672c1e013e667ec8c46231e0e7abcf97ba35d89fceb8edae45",
"chains": null,
"service_url": "validator-004-pocket-validator:42069",
"service_url": "validator-004-pocket:42069",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand All @@ -4102,7 +4102,7 @@ data:
"address": "43d9ea9d9ad9c58bb96ec41340f83cb2cabb6496",
"public_key": "16cd0a304c38d76271f74dd3c90325144425d904ef1b9a6fbab9b201d75a998b",
"chains": ["0001"],
"service_url": "validator-001-pocket-validator:42069",
"service_url": "validator-001-pocket:42069",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand All @@ -4115,7 +4115,7 @@ data:
"address": "9ba047197ec043665ad3f81278ab1f5d3eaf6b8b",
"public_key": "68efd26af01692fcd77dc135ca1de69ede464e8243e6832bd6c37f282db8c9cb",
"chains": ["0001"],
"service_url": "validator-001-pocket-validator:42069",
"service_url": "validator-001-pocket:42069",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand Down
4 changes: 4 additions & 0 deletions charts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.0.0.3] - 2023-04-19

- Rename `pocket-validator` to `pocket`, as we are not going to ship different artifacts, but will have just one.

## [0.0.0.2] - 2023-04-17

- Removed `runtime/configs.Config#UseLibp2p` field
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
name: pocket-validator
name: pocket
description: Validator for Pocket Network - decentralized blockchain infrastructure
home: https://pokt.network
sources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</a>
</div>

# pocket-validator
# pocket

Validator for Pocket Network - decentralized blockchain infrastructure

Expand Down Expand Up @@ -118,6 +118,7 @@ privateKeySecretKeyRef:
| resources | object | `{}` | resources limits and requests |
| securityContext | object | `{}` | |
| service.annotations | object | `{}` | service annotations |
| service.nameOverride | string | `""` | |
| service.ports.consensus | int | `42069` | consensus port of the node |
| service.ports.metrics | int | `9000` | OpenTelemetry metrics port of the node |
| service.ports.rpc | int | `50832` | rpc port of the node |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "pocket-validator.name" -}}
{{- define "pocket.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

Expand All @@ -10,7 +10,7 @@ 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 "pocket-validator.fullname" -}}
{{- define "pocket.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
Expand All @@ -26,16 +26,16 @@ If release name contains chart name it will be used as a full name.
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "pocket-validator.chart" -}}
{{- define "pocket.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "pocket-validator.labels" -}}
helm.sh/chart: {{ include "pocket-validator.chart" . }}
{{ include "pocket-validator.selectorLabels" . }}
{{- define "pocket.labels" -}}
helm.sh/chart: {{ include "pocket.chart" . }}
{{ include "pocket.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
Expand All @@ -45,18 +45,18 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{/*
Selector labels
*/}}
{{- define "pocket-validator.selectorLabels" -}}
app.kubernetes.io/name: {{ include "pocket-validator.name" . }}
{{- define "pocket.selectorLabels" -}}
app.kubernetes.io/name: {{ include "pocket.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
pokt.network/purpose: validator
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "pocket-validator.serviceAccountName" -}}
{{- define "pocket.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "pocket-validator.fullname" .) .Values.serviceAccount.name }}
{{- default (include "pocket.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
Expand All @@ -65,7 +65,7 @@ Create the name of the service account to use
{{/*
Determine the PostgreSQL hostname based on whether the subchart is enabled.
*/}}
{{- define "pocket-validator.postgresqlHost" -}}
{{- define "pocket.postgresqlHost" -}}
{{- if .Values.postgresql.enabled -}}
{{- printf "%s-%s" .Release.Name "postgresql" -}}
{{- else -}}
Expand All @@ -76,7 +76,7 @@ Determine the PostgreSQL hostname based on whether the subchart is enabled.
{{/*
Determine the PostgreSQL port based on whether the subchart is enabled.
*/}}
{{- define "pocket-validator.postgresqlPort" -}}
{{- define "pocket.postgresqlPort" -}}
{{- if .Values.postgresql.enabled -}}
{{- .Values.global.postgresql.service.ports.postgresql | toString -}}
{{- else -}}
Expand All @@ -87,7 +87,7 @@ Determine the PostgreSQL port based on whether the subchart is enabled.
{{/*
Determine the PostgreSQL schema based on whether the subchart is enabled.
*/}}
{{- define "pocket-validator.postgresqlDatabase" -}}
{{- define "pocket.postgresqlDatabase" -}}
{{- if .Values.postgresql.enabled -}}
{{- "postgres" -}}
{{- else -}}
Expand All @@ -98,14 +98,14 @@ Determine the PostgreSQL schema based on whether the subchart is enabled.
{{/*
Determine the PostgreSQL schema based on whether the subchart is enabled.
*/}}
{{- define "pocket-validator.postgresqlSchema" -}}
{{- define "pocket.postgresqlSchema" -}}
{{- .Values.config.persistence.node_schema -}}
{{- end -}}

{{/*
Determine the PostgreSQL user SecretKeyRef based on whether the subchart is enabled.
*/}}
{{- define "pocket-validator.postgresqlUserValueOrSecretRef" -}}
{{- define "pocket.postgresqlUserValueOrSecretRef" -}}
{{- if .Values.postgresql.enabled -}}
value: postgres
{{- else -}}
Expand All @@ -119,7 +119,7 @@ valueFrom:
{{/*
Determine the PostgreSQL password SecretKeyRef based on whether the subchart is enabled.
*/}}
{{- define "pocket-validator.postgresqlPasswordSecretKeyRef" -}}
{{- define "pocket.postgresqlPasswordSecretKeyRef" -}}
{{- if .Values.postgresql.enabled -}}
valueFrom:
secretKeyRef:
Expand All @@ -136,9 +136,9 @@ valueFrom:
{{/*
Determine the genesis ConfigMap based on whether pre-provisioned genesis is enabled.
*/}}
{{- define "pocket-validator.genesisConfigMap" -}}
{{- define "pocket.genesisConfigMap" -}}
{{- if .Values.genesis.preProvisionedGenesis.enabled -}}
{{- printf "%s-%s" (include "pocket-validator.fullname" .) "genesis" -}}
{{- printf "%s-%s" (include "pocket.fullname" .) "genesis" -}}
{{- else -}}
{{- .Values.genesis.externalConfigMap.name -}}
{{- end -}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "pocket-validator.fullname" . }}-config
name: {{ include "pocket.fullname" . }}-config
labels:
{{- include "pocket-validator.labels" . | nindent 4 }}
{{- include "pocket.labels" . | nindent 4 }}
data:
config.json: |
{{ .Values.config | toPrettyJson | nindent 4 }}
Loading