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

[quorum] implement istanbul_propose method to add or remove a node #2516

Merged
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
20 changes: 20 additions & 0 deletions platforms/quorum/charts/quorum-propose-validator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v1
name: quorum-propose-validator
description: "Quorum: Proposes to add or remove a validator with the specified address."
version: 1.0.1
appVersion: latest
keywords:
- bevel
- ethereum
- quorum
- hyperledger
- enterprise
- blockchain
- deployment
- accenture
home: https://hyperledger-bevel.readthedocs.io/en/latest/
sources:
- https://github.com/hyperledger/bevel
maintainers:
- name: Hyperledger Bevel maintainers
email: bevel@lists.hyperledger.org
92 changes: 92 additions & 0 deletions platforms/quorum/charts/quorum-propose-validator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
[//]: # (##############################################################################################)
[//]: # (Copyright Accenture. All Rights Reserved.)
[//]: # (SPDX-License-Identifier: Apache-2.0)
[//]: # (##############################################################################################)

# goquorum-propose-validator

This chart is a component of Hyperledger Bevel. The goquorum-propose-validator chart injects a new authorization candidate that the validator attempts to push through. If a majority of the validators vote the candidate in/out, the candidate is added/removed in the validator set.

## TL;DR

```bash
helm repo add bevel https://hyperledger.github.io/bevel
helm install propose-validator bevel/goquorum-propose-validator
```

## Prerequisitess

- Kubernetes 1.19+
- Helm 3.2.0+

If Hashicorp Vault is used, then
- HashiCorp Vault Server 1.13.1+

> **Important**: Also check the dependent charts.

## Installing the Chart

To install the chart with the release name `propose-validator`:

```bash
helm repo add bevel https://hyperledger.github.io/bevel
helm install propose-validator bevel/goquorum-propose-validator
```

The command deploys the chart on the Kubernetes cluster in the default configuration. The [Parameters](#parameters) section lists the parameters that can be configured during installation.

> **Tip**: List all releases using `helm list`

## Uninstalling the Chart

To uninstall/delete the `propose-validator` deployment:

```bash
helm uninstall propose-validator
```

The command removes all the Kubernetes components associated with the chart and deletes the release.

## Parameters

### Image

| Name | Description | Default Value |
| -------------| ---------- | --------- |
| `image.genesisUtils.repository` | Quorum hooks image repository | `ghcr.io/hyperledger/bevel-k8s-hooks` |
| `image.genesisUtils.tag` | Quorum hooks image tag | `qgt-0.2.12` |
| `image.pullSecret` | Provide the docker secret name in the namespace | `""` |
| `image.pullPolicy` | Pull policy to be used for the Docker images | `IfNotPresent` |

### validators

| Name | Description | Default Value |
| ----------------| ----------- | ------------- |
| `validators.auth` | Set to 'true' to vote the candidate in and 'false' to vote them out | `true` |
| `validators.authorizedValidatorsURL` | URLs of already authorized validators | `""` |
| `validators.nonAuthorizedValidatorsNodeAddress` | Node addresses of the validators that need to be proposed | `""` |


## License

This chart is licensed under the Apache v2.0 license.

Copyright © 2023 Accenture

### Attribution

This chart is adapted from the [charts](https://hyperledger.github.io/bevel/) which is licensed under the Apache v2.0 License which is reproduced here:

```
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "quorum-propose-validator.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 "quorum-propose-validator.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "quorum-propose-validator.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "quorum-propose-validator.name" . }}
namespace: {{ .Release.Namespace }}
labels:
app: {{ .Release.Name }}
app.kubernetes.io/name: quorum-propose-validator-job
app.kubernetes.io/component: propose-validator-job
app.kubernetes.io/part-of: {{ include "quorum-propose-validator.fullname" . }}
app.kubernetes.io/namespace: {{ .Release.Namespace }}
app.kubernetes.io/release: {{ .Release.Name }}
app.kubernetes.io/managed-by: helm
spec:
backoffLimit: 3
template:
metadata:
labels:
app: {{ .Release.Name }}
app.kubernetes.io/name: quorum-propose-validator-job
app.kubernetes.io/component: propose-validator-job
app.kubernetes.io/part-of: {{ include "quorum-propose-validator.fullname" . }}
app.kubernetes.io/namespace: {{ .Release.Namespace }}
app.kubernetes.io/managed-by: helm
spec:
restartPolicy: "OnFailure"
containers:
- name: propose-validator
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
securityContext:
runAsUser: 0
env:
- name: EXISTING_VALIDATOR_URLS
value: "{{- .Values.validators.existingValidators | join " " -}}"
- name: PROPOSE_VALIDATOR_ADDRS
value: "{{- .Values.validators.proposeValidatorsAddr | join " " -}}"
command: ["/bin/sh", "-c"]
args:
- |

for propose_val_addr in $PROPOSE_VALIDATOR_ADDRS; do
for existing_val_url in $EXISTING_VALIDATOR_URLS; do
# Send proposal to the existing validator
proposal_response=$(curl -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"{{ .Values.validators.consensusMethod}}","params":["'"$propose_val_addr"'",{{ .Values.validators.auth }}],"id":1}' "$existing_val_url")

# Check if proposal was successful or not
result_count=$(echo "$proposal_response" | grep -c "result")
if [ "$result_count" = 1 ]; then
echo "Node proposed successfully."
else
echo "$proposal_response" | jq -r '.error'
fi
done
done
echo "COMPLETED"
20 changes: 20 additions & 0 deletions platforms/quorum/charts/quorum-propose-validator/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
image:
repository: ghcr.io/hyperledger/bevel-k8s-hooks
tag: qgt-0.2.12
pullPolicy: IfNotPresent
pullSecret: ""

validators:
consensusMethod: "istanbul_propose"
auth: true # Set to 'true' to vote the candidate in and 'false' to vote them out
# List of URLs of the existing validators
existingValidators:
# - "http://<test-1.yourDomain.com>"
# - "http://<test-2.yourDomain.com>"
# - "http://<test-3.yourDomain.com>"
# - "http://<test-4.yourDomain.com>"
# List of node addresses of the validators that need to be proposed
proposeValidatorsAddr:
# - "<0xnodeAddress-1>"
# - "<0xnodeAddress-2>"
# - "<0xnodeAddress-3>"
Loading