From 4c33e04bf5c911aa21e0d2464402096de01004bb Mon Sep 17 00:00:00 2001 From: Enderson Maia Date: Mon, 13 Nov 2023 15:46:24 +0000 Subject: [PATCH] feat: adapt to rollups-node:1.2.0 --- charts/rollups-node/Chart.yaml | 2 +- .../rollups-node/ci/localnode-values.yaml.tpl | 13 +- charts/rollups-node/ci/test-values.yaml.tpl | 45 ++++- charts/rollups-node/templates/_helpers.tpl | 7 + .../authority-claimer-deployment.yaml | 157 ++++++++++++++++++ .../templates/dapp-configmap.yaml | 21 --- .../templates/dispatcher-deployment.yaml | 34 +--- charts/rollups-node/values.yaml | 103 +++++++++++- 8 files changed, 322 insertions(+), 60 deletions(-) create mode 100644 charts/rollups-node/templates/authority-claimer-deployment.yaml delete mode 100644 charts/rollups-node/templates/dapp-configmap.yaml diff --git a/charts/rollups-node/Chart.yaml b/charts/rollups-node/Chart.yaml index f1b0912..2e922d6 100644 --- a/charts/rollups-node/Chart.yaml +++ b/charts/rollups-node/Chart.yaml @@ -13,7 +13,7 @@ maintainers: url: https://github.com/oap75 type: application -version: 1.1.0-1 +version: 1.2.0-0 dependencies: - name: redis diff --git a/charts/rollups-node/ci/localnode-values.yaml.tpl b/charts/rollups-node/ci/localnode-values.yaml.tpl index 0236b6f..e6c9755 100644 --- a/charts/rollups-node/ci/localnode-values.yaml.tpl +++ b/charts/rollups-node/ci/localnode-values.yaml.tpl @@ -12,8 +12,17 @@ extraDeploy: RD_EPOCH_DURATION: "86400" SC_GRPC_ENDPOINT: 'http://{{ include "validator.fullname" . }}-state-server:50051' SC_DEFAULT_CONFIRMATIONS: "1" + - apiVersion: v1 + kind: ConfigMap + metadata: + namespace: "{{ .Release.Namespace }}" + name: "{{ .Release.Name }}-authority-claimer" + data: + RUST_LOG: "info" + RD_EPOCH_DURATION: "86400" + SC_GRPC_ENDPOINT: 'http://{{ include "validator.fullname" . }}-state-server:50051' TX_CHAIN_IS_LEGACY: "false" - TX_DEFAULT_CONFIRMATIONS: "2" + SC_DEFAULT_CONFIRMATIONS: "1" - apiVersion: v1 kind: ConfigMap metadata: @@ -49,6 +58,8 @@ localnode: enabled: true dispatcher: extraEnvVarsCM: "{{ .Release.Name }}-dispatcher" +authorityClaimer: + extraEnvVarsCM: "{{ .Release.Name }}-authority-claimer" stateServer: extraEnvVarsCM: "{{ .Release.Name }}-state-server" serverManager: diff --git a/charts/rollups-node/ci/test-values.yaml.tpl b/charts/rollups-node/ci/test-values.yaml.tpl index 97e8c54..22433e8 100644 --- a/charts/rollups-node/ci/test-values.yaml.tpl +++ b/charts/rollups-node/ci/test-values.yaml.tpl @@ -11,6 +11,20 @@ dapp: network: sepolia extraDeploy: + - apiVersion: v1 + kind: ConfigMap + metadata: + namespace: "{{ .Release.Namespace }}" + name: "{{ .Release.Name }}-sepolia-deployment" + data: + "sepolia.json": | + { + "contracts": { + "Authority": { "address": "0x5827Ec9365D3a9b27bF1dB982d258Ad234D37242" }, + "History": { "address": "0x76f4dCaC0920826541EE718214EEE4be07346cEE" }, + "InputBox": { "address": "0x59b22D57D4f067708AB0c00552767405926dc768" } + } + } - apiVersion: v1 kind: ConfigMap metadata: @@ -21,8 +35,19 @@ extraDeploy: RD_EPOCH_DURATION: "86400" SC_GRPC_ENDPOINT: "http://localhost:50051" SC_DEFAULT_CONFIRMATIONS: "1" + ROLLUPS_DEPLOYMENT_FILE: "/opt/cartesi/share/deployments/sepolia.json" + - apiVersion: v1 + kind: ConfigMap + metadata: + namespace: "{{ .Release.Namespace }}" + name: "{{ .Release.Name }}-authority-claimer" + data: + RUST_LOG: "info" + RD_EPOCH_DURATION: "86400" + SC_GRPC_ENDPOINT: 'http://{{ include "validator.fullname" . }}-state-server:50051' TX_CHAIN_IS_LEGACY: "false" - TX_DEFAULT_CONFIRMATIONS: "2" + SC_DEFAULT_CONFIRMATIONS: "1" + ROLLUPS_DEPLOYMENT_FILE: "/opt/cartesi/share/deployments/sepolia.json" - apiVersion: v1 kind: ConfigMap metadata: @@ -60,6 +85,24 @@ dispatcher: extraEnvVarsCM: "{{ .Release.Name }}-dispatcher" healthCheck: enabled: true + extraVolumes: + - name: sepolia-deployment + configMap: + name: "{{ .Release.Name }}-sepolia-deployment" + extraVolumeMounts: + - name: sepolia-deployment + mountPath: /opt/cartesi/share/deployments + readOnly: true +authorityClaimer: + extraEnvVarsCM: "{{ .Release.Name }}-authority-claimer" + extraVolumes: + - name: sepolia-deployment + configMap: + name: "{{ .Release.Name }}-sepolia-deployment" + extraVolumeMounts: + - name: sepolia-deployment + mountPath: /opt/cartesi/share/deployments + readOnly: true stateServer: extraEnvVarsCM: "{{ .Release.Name }}-state-server" serverManager: diff --git a/charts/rollups-node/templates/_helpers.tpl b/charts/rollups-node/templates/_helpers.tpl index f1582f3..9a999b5 100644 --- a/charts/rollups-node/templates/_helpers.tpl +++ b/charts/rollups-node/templates/_helpers.tpl @@ -141,6 +141,13 @@ Return the proper dispatcher image name {{ include "images.image" (dict "imageRoot" .Values.dispatcher.image "global" .Values.global) }} {{- end -}} +{{/* +Return the proper authorityClaimer image name +*/}} +{{- define "authorityClaimer.image" -}} +{{ include "images.image" (dict "imageRoot" .Values.authorityClaimer.image "global" .Values.global) }} +{{- end -}} + {{/* Return the proper stateServer image name */}} diff --git a/charts/rollups-node/templates/authority-claimer-deployment.yaml b/charts/rollups-node/templates/authority-claimer-deployment.yaml new file mode 100644 index 0000000..3ce285f --- /dev/null +++ b/charts/rollups-node/templates/authority-claimer-deployment.yaml @@ -0,0 +1,157 @@ +{{- /* +(c) Cartesi and individual authors (see AUTHORS) +SPDX-License-Identifier: Apache-2.0 (see LICENSE) +*/}} + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "validator.fullname" . }}-authority-claimer + labels: {{- include "validator.labels" . | nindent 4 }} +spec: + replicas: 1 + selector: + matchLabels: + {{- include "validator.selectorLabels" . | nindent 6 }} + rollups.cartesi.io/component: authority-claimer + template: + metadata: + {{- with .Values.authorityClaimer.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "validator.selectorLabels" . | nindent 8 }} + rollups.cartesi.io/component: authority-claimer + spec: + {{- with .Values.image.pullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "validator.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.authorityClaimer.podSecurityContext | nindent 8 }} + initContainers: + {{- if .Values.authorityClaimer.initContainers }} + {{- include "tplvalues.render" ( dict "value" .Values.authorityClaimer.initContainers "context" $ ) | nindent 8 }} + {{- end }} + containers: + - name: rollups-authority-claimer + image: {{ include "authorityClaimer.image" . }} + imagePullPolicy: {{ .Values.image.pullPolicy }} + resources: + {{- toYaml .Values.authorityClaimer.resources | nindent 12 }} + {{- if .Values.authorityClaimer.command }} + command: + {{- include "tplvalues.render" (dict "value" .Values.authorityClaimer.command "context" $) | nindent 12 }} + {{- end }} + args: + {{- if .Values.authorityClaimer.healthCheck.enabled }} + - {{ print "--http-server-port=" (default .Values.authorityClaimer.healthCheck.port 8086) | quote }} + {{- end }} + {{- if .Values.localnode.enabled }} + - --rollups-deployment-file=/opt/cartesi/share/deployments/localhost.json + - --dapp-deployment-file=/deployments/localhost/dapp.json + {{- else }} + - {{ print "--dapp-address=" (required "A valid .Values.dapp.contractAddress is required" .Values.dapp.contractAddress) | quote }} + - {{ print "--dapp-deploy-block-hash=" (required "A valid .Values.dapp.blockHash is required" .Values.dapp.blockHash) | quote }} + {{- end }} + {{- if (or .Values.dapp.mnemonic.value .Values.dapp.mnemonic.secretRef .Values.localnode.enabled) }} + - {{ print "--tx-signing-mnemonic-file=/var/run/secrets/mnemonic/MNEMONIC" | quote }} + {{- end }} + {{- if .Values.localnode.enabled }} + - --tx-provider-http-endpoint=http://{{ include "validator.fullname" . }}-localnode:8545 + {{- else }} + - {{ print "--tx-provider-http-endpoint=" (required "A valid .Values.dapp.httpProvider is required" .Values.dapp.httpProvider) | quote }} + {{- end }} + {{- if (or .Values.dapp.network .Values.localnode.enabled) }} + - {{ print "--tx-chain-id=" (include "dapp.chainID" .) | quote }} + {{- end }} + - {{ print (include "validator.redisConfig" .) | quote }} + {{- range .Values.authorityClaimer.args }} + - {{ . | quote}} + {{- end }} + {{- range .Values.authorityClaimer.extraArgs }} + - {{ . | quote}} + {{- end }} + {{- if .Values.authorityClaimer.healthCheck.enabled }} + livenessProbe: + httpGet: + path: /healthz + port: {{ (default 8086 .Values.authorityClaimer.healthCheck.port) }} + initialDelaySeconds: 3 + {{- end }} + env: + - name: RUST_LOG + value: {{ .Values.authorityClaimer.logLevel }} + {{- if .Values.authorityClaimer.extraEnvVars }} + {{- include "tplvalues.render" (dict "value" .Values.authorityClaimer.extraEnvVars "context" $) | nindent 12 }} + {{- end }} + {{- if or .Values.authorityClaimer.extraEnvVarsCM .Values.authorityClaimer.extraEnvVarsSecret }} + envFrom: + {{- if .Values.authorityClaimer.extraEnvVarsCM }} + - configMapRef: + name: {{ include "tplvalues.render" ( dict "value" .Values.authorityClaimer.extraEnvVarsCM "context" $ ) }} + {{- end }} + {{- if .Values.authorityClaimer.extraEnvVarsSecret }} + - secretRef: + name: {{ include "tplvalues.render" ( dict "value" .Values.authorityClaimer.extraEnvVarsSecret "context" $ ) }} + {{- end }} + {{- end }} + volumeMounts: + {{- if (or .Values.dapp.mnemonic.value .Values.localnode.enabled .Values.dapp.mnemonic.secretRef) }} + - name: mnemonic + mountPath: /var/run/secrets/mnemonic + readOnly: true + {{- end }} + - name: authority-claimer-lib + mountPath: /opt/cartesi/rollups-authority-claimer/lib + readOnly: false + {{- if .Values.localnode.enabled }} + - name: blockchain-data + mountPath: /opt/cartesi/share/deployments + readOnly: false + - name: deployments + mountPath: /deployments + readOnly: false + {{- end}} + {{- if .Values.authorityClaimer.extraVolumeMounts }} + {{- include "tplvalues.render" ( dict "value" .Values.authorityClaimer.extraVolumeMounts "context" $ ) | nindent 12 }} + {{- end }} + + volumes: + {{- if .Values.localnode.enabled }} + - name: blockchain-data + persistentVolumeClaim: + claimName: {{ include "validator.fullname" . }}-blockchain-data-pvc + - name: deployments + persistentVolumeClaim: + claimName: {{ include "validator.fullname" . }}-deployments-pvc + {{- end }} + - name: authority-claimer-lib + emptyDir: {} + {{- if (or .Values.dapp.mnemonic.value .Values.localnode.enabled .Values.dapp.mnemonic.secretRef) }} + - name: mnemonic + secret: + {{- if (or .Values.dapp.mnemonic.value .Values.localnode.enabled) }} + secretName: {{ include "validator.fullname" . }}-mnemonic + {{- else }} + secretName: {{ .Values.dapp.mnemonic.secretRef }} + {{- end }} + {{- end }} + {{- if .Values.authorityClaimer.extraVolumes }} + {{- include "tplvalues.render" ( dict "value" .Values.authorityClaimer.extraVolumes "context" $ ) | nindent 8 }} + {{- end }} + {{- with .Values.authorityClaimer.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.authorityClaimer.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.authorityClaimer.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/rollups-node/templates/dapp-configmap.yaml b/charts/rollups-node/templates/dapp-configmap.yaml deleted file mode 100644 index 0f418a3..0000000 --- a/charts/rollups-node/templates/dapp-configmap.yaml +++ /dev/null @@ -1,21 +0,0 @@ -{{- /* -(c) Cartesi and individual authors (see AUTHORS) -SPDX-License-Identifier: Apache-2.0 (see LICENSE) -*/}} - ---- -{{- if not .Values.localnode.enabled }} -kind: ConfigMap -apiVersion: v1 -metadata: - name: {{ include "validator.fullname" . }}-dapp - labels: {{- include "validator.labels" . | nindent 4 }} -data: - "dapp.json": | - { - "address": {{ required "A valid .Values.dapp.contractAddress is required" .Values.dapp.contractAddress | quote }}, - "blockHash": {{ required "A valid .Values.dapp.blockHash is required" .Values.dapp.blockHash | quote }}, - "blockNumber": {{ required "A valid .Values.dapp.blockNumber is required" .Values.dapp.blockNumber | int64 | quote }}, - "transactionHash": {{ required "A valid .Values.dapp.transactionHash is required" .Values.dapp.transactionHash | quote }} - } -{{ end -}} diff --git a/charts/rollups-node/templates/dispatcher-deployment.yaml b/charts/rollups-node/templates/dispatcher-deployment.yaml index 9d5f86c..0bcb086 100644 --- a/charts/rollups-node/templates/dispatcher-deployment.yaml +++ b/charts/rollups-node/templates/dispatcher-deployment.yaml @@ -52,26 +52,17 @@ spec: - {{ print "--http-server-port=" (default .Values.dispatcher.healthCheck.port 8081) | quote }} {{- end }} {{- if .Values.localnode.enabled }} - - --rd-rollups-deployment-file=/opt/cartesi/share/deployments/localhost.json - - --rd-dapp-deployment-file=/deployments/localhost/dapp.json + - --rollups-deployment-file=/opt/cartesi/share/deployments/localhost.json + - --dapp-deployment-file=/deployments/localhost/dapp.json {{- else }} - - {{ print "--rd-rollups-deployment-file=/opt/cartesi/share/deployments/" (required "A valid .Values.dapp.network is required" .Values.dapp.network | replace "-" "_") ".json" | quote }} - - {{ print "--rd-dapp-deployment-file=/deployments/" (required "A valid .Values.dapp.network is required" .Values.dapp.network | replace "-" "_") "/dapp.json" | quote }} - {{- end }} - {{- if (or .Values.dapp.mnemonic.value .Values.dapp.mnemonic.secretRef .Values.localnode.enabled) }} - - {{ print "--auth-mnemonic-file=/var/run/secrets/mnemonic/MNEMONIC" | quote }} - {{- end }} - {{- if .Values.localnode.enabled }} - - --tx-provider-http-endpoint=http://{{ include "validator.fullname" . }}-localnode:8545 - {{- else }} - - {{ print "--tx-provider-http-endpoint=" (required "A valid .Values.dapp.httpProvider is required" .Values.dapp.httpProvider) | quote }} + - {{ print "--dapp-address=" (required "A valid .Values.dapp.contractAddress is required" .Values.dapp.contractAddress) | quote }} + - {{ print "--dapp-deploy-block-hash=" (required "A valid .Values.dapp.blockHash is required" .Values.dapp.blockHash) | quote }} {{- end }} {{- if (or .Values.dapp.network .Values.localnode.enabled) }} - - {{ print "--tx-chain-id=" (include "dapp.chainID" .) | quote }} + - {{ print "--chain-id=" (include "dapp.chainID" .) | quote }} {{- end }} - {{ print (include "validator.redisConfig" .) | quote }} {{- range .Values.dispatcher.args }} - - {{ . | quote}} {{- end }} {{- range .Values.dispatcher.extraArgs }} - {{ . | quote}} @@ -106,9 +97,6 @@ spec: mountPath: /var/run/secrets/mnemonic readOnly: true {{- end }} - - name: dispatcher-lib - mountPath: /opt/cartesi/rollups-dispatcher/lib - readOnly: false {{- if .Values.localnode.enabled }} - name: blockchain-data mountPath: /opt/cartesi/share/deployments @@ -116,10 +104,6 @@ spec: - name: deployments mountPath: /deployments readOnly: false - {{- else }} - - name: dapp - mountPath: "/deployments/{{ .Values.dapp.network }}/" - readOnly: true {{- end}} {{- if .Values.dispatcher.extraVolumeMounts }} {{- include "tplvalues.render" ( dict "value" .Values.dispatcher.extraVolumeMounts "context" $ ) | nindent 12 }} @@ -134,14 +118,6 @@ spec: persistentVolumeClaim: claimName: {{ include "validator.fullname" . }}-deployments-pvc {{- end }} - - name: dispatcher-lib - emptyDir: {} - - name: dapp - configMap: - name: "{{ include "validator.fullname" . }}-dapp" - items: - - key: "dapp.json" - path: "dapp.json" {{- if (or .Values.dapp.mnemonic.value .Values.localnode.enabled .Values.dapp.mnemonic.secretRef) }} - name: mnemonic secret: diff --git a/charts/rollups-node/values.yaml b/charts/rollups-node/values.yaml index 0e1ca4f..704ecb5 100644 --- a/charts/rollups-node/values.yaml +++ b/charts/rollups-node/values.yaml @@ -13,12 +13,6 @@ dapp: # -- the block hash of the block where the dapp was deployed # (REQUIRED) blockHash: - # -- the block number of the block where the dapp was deployed - # (REQUIRED) - blockNumber: - # -- dapp.transactionHash is the transaction hash of the transaction that deployed the dapp - # (REQUIRED) - transactionHash: # -- mnemonic defines the configuration for the mnemonic # use value or secretRef, never both @@ -54,7 +48,7 @@ global: # -- Global Docker image registry registry: docker.io # -- Global Docker Image tag - tag: 1.1.0 + tag: 1.2.0 ## seviceAccount configuration to be used by the rollups-validator-node ## @@ -374,6 +368,101 @@ dispatcher: # -- Optionally specify extra list of additional volumeMounts for the dispatcher container(s) extraVolumeMounts: [] +authorityClaimer: + # -- Set the authorityClaimer docker image + image: + registry: + repository: cartesi/rollups-node + tag: + digest: + + # -- Node labels for validator pods assignment + nodeSelector: {} + + # -- Tolerations for validator pods assignment + tolerations: [] + + # -- Affinity for validator pods assignment + affinity: {} + + # -- add additional init containers to the authorityClaimer pod(s) + ## Example + ## + ## initContainers: + ## - name: do-something + ## image: busybox + ## command: ['do', 'something'] + ## + initContainers: [] + + # -- validator replicas pod's Security Context + podSecurityContext: + {} + ## fsGroup: 2000 + + # -- Annotations for Validator replicas pods + podAnnotations: {} + + # -- Optionally specify extra list of additional volumes for the validator pod(s) + extraVolumes: [] + + # -- The RUST_LOG level can be set to trace, debug, info, warn, error, or off. + logLevel: info + + healthCheck: + # -- enable/disable health check for authorityClaimer + enabled: true + # -- define the health check port for authorityClaimer + port: 8086 + + # -- Override default container command (useful when using custom images) + command: ["cartesi-rollups-authority-claimer"] + + # -- Override default container args (useful when using custom images) + args: [] + + # -- Extra arguments for authorityClaimer + extraArgs: [] + + # -- Array with extra environment variables to add to validator.authorityClaimer container + ## e.g: + ## extraEnvVars: + ## - name: FOO + ## value: "bar" + ## + extraEnvVars: [] + + # -- Name of existing ConfigMap containing extra env vars for authorityClaimer container + ## + extraEnvVarsCM: "" + + # -- Name of existing Secret containing extra env vars for authorityClaimer container + ## + extraEnvVarsSecret: "" + + # -- Set authorityClaimer container Security Context + securityContext: + {} + ## capabilities: + ## drop: + ## - ALL + ## readOnlyRootFilesystem: true + ## runAsNonRoot: true + ## runAsUser: 1000 + + # -- Set authorityClaimer container resources + resources: + {} + ## limits: + ## cpu: 100m + ## memory: 128Mi + ## requests: + ## cpu: 100m + ## memory: 128Mi + + # -- Optionally specify extra list of additional volumeMounts for the authorityClaimer container(s) + extraVolumeMounts: [] + stateServer: # -- Set the stateServer docker image image: