From fced193ba7fef1fbfe39633c7df55dd3087340ef Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Fri, 14 Apr 2023 17:53:38 -0700 Subject: [PATCH 01/65] introduce smart rollups statefulsets --- charts/tezos/scripts/smart-rollup-node.sh | 14 ++++ charts/tezos/templates/configs.yaml | 2 + charts/tezos/templates/octez-rollup-node.yaml | 84 +++++++++++++++++++ charts/tezos/values.yaml | 21 +++++ utils/config-generator.py | 6 ++ 5 files changed, 127 insertions(+) create mode 100644 charts/tezos/scripts/smart-rollup-node.sh create mode 100644 charts/tezos/templates/octez-rollup-node.yaml diff --git a/charts/tezos/scripts/smart-rollup-node.sh b/charts/tezos/scripts/smart-rollup-node.sh new file mode 100644 index 000000000..54eb910da --- /dev/null +++ b/charts/tezos/scripts/smart-rollup-node.sh @@ -0,0 +1,14 @@ +set -ex + +TEZ_VAR=/var/tezos +TEZ_BIN=/usr/local/bin +CLIENT_DIR="$TEZ_VAR/client" +NODE_DIR="$TEZ_VAR/node" +NODE_DATA_DIR="$TEZ_VAR/node/data" + +CMD="$TEZ_BIN/octez-smart-rollup-node-alpha -d $CLIENT_DIR run operator for ${ROLLUP_ADDRESS} with operators ${OPERATOR_ACCOUNT}" + +# ensure we can run tezos-signer commands without specifying client dir +ln -s /var/tezos/client /home/tezos/.tezos-signer + +exec $CMD diff --git a/charts/tezos/templates/configs.yaml b/charts/tezos/templates/configs.yaml index 84ea560de..69c758f0d 100644 --- a/charts/tezos/templates/configs.yaml +++ b/charts/tezos/templates/configs.yaml @@ -58,6 +58,8 @@ data: {{- $_ := set $tacoinfraSigners $signerName (pick $signerConfig "accounts") }} {{- end }} {{ $tacoinfraSigners | default dict | mustToPrettyJson | indent 4 }} + OCTEZ_ROLLUP_NODES: | +{{ $.Values.smartRollupNodes | default dict | mustToPrettyJson | indent 4 }} --- diff --git a/charts/tezos/templates/octez-rollup-node.yaml b/charts/tezos/templates/octez-rollup-node.yaml new file mode 100644 index 000000000..f3de83243 --- /dev/null +++ b/charts/tezos/templates/octez-rollup-node.yaml @@ -0,0 +1,84 @@ +{{- range $k, $v := .Values.smartRollupNodes }} + +apiVersion: v1 +kind: Service +metadata: + name: {{ $.Values.smart_rollup_node_statefulset.name }} + namespace: {{ $.Release.Namespace }} +spec: + clusterIP: None + ports: + - port: 8080 + name: web + selector: + app: {{ $.Values.smart_rollup_node_statefulset.name }} +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ $k }} + namespace: {{ $.Release.Namespace }} +spec: + podManagementPolicy: Parallel + replicas: 1 + serviceName: {{ $.Values.smart_rollup_node_statefulset.name }} + selector: + matchLabels: + app: {{ $.Values.smart_rollup_node_statefulset.name }} + template: + metadata: + labels: + app: {{ $.Values.smart_rollup_node_statefulset.name }} + spec: + containers: + - name: octez-smart-rollup-node + image: "{{ $.Values.images.octez }}" + imagePullPolicy: IfNotPresent + ports: + - containerPort: 8080 + name: web + command: + - /bin/sh + volumeMounts: + - mountPath: /var/tezos + name: var-volume + args: + - "-c" + - | +{{ tpl ($.Files.Get "scripts/smart-rollup-node.sh") $ | indent 12 }} + env: + - name: ROLLUP_ADDRESS + value: {{ $v.rollup_address }} + - name: OPERATOR_ACCOUNT + value: {{ $v.operator_account }} + initContainers: + - image: {{ $.Values.tezos_k8s_images.utils }} + imagePullPolicy: IfNotPresent + name: config-generator + args: + - "config-generator" + envFrom: + - configMapRef: + name: tezos-config + env: + - name: MY_POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: MY_POD_TYPE + value: {{ $.Values.smart_rollup_node_statefulset.pod_type }} + volumeMounts: + - mountPath: /var/tezos + name: var-volume + - mountPath: /etc/secret-volume + name: tezos-accounts + securityContext: + fsGroup: 1000 + volumes: + - emptyDir: {} + name: var-volume + - name: tezos-accounts + secret: + secretName: tezos-secret +--- +{{- end }} diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index ca5bf4baf..73a3fecc5 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -27,6 +27,9 @@ octez_signer_statefulset: chain_initiator_job: name: chain-initiator pod_type: activating +smart_rollup_node_statefulset: + name: smart-rollup + pod_type: rollup # For non-public chains the default mutez given to an account if the # account is not explicitly set below. @@ -326,6 +329,24 @@ tacoinfraSigners: {} # ``` # End Signers +# # Rollup nodes +# +# Define remote signers. Bakers automatically use signers in their namespace +# that are configured to sign for the accounts they are baking for. +# By default no signer is configured. +# +# https://tezos.gitlab.io/user/key-management.html#signer +smartRollupNodes: {} +# Example: +# ``` +# smartRollupNodes: +# rollup-node-0: +# operator_account: archive-baking-node-0 +# rollup_address: sr1RYurGZtN8KNSpkMcCt9CgWeUaNkzsAfXf +# ``` + +# End Rollup Nodes + # When spinning up nodes, tezos-k8s will attempt to download a snapshot from a # known source. This should be a url to a json metadata file in the format # xtz-shots uses. If you want to sync from scratch or for a private chain, set diff --git a/utils/config-generator.py b/utils/config-generator.py index 35f1c832c..6f144705f 100755 --- a/utils/config-generator.py +++ b/utils/config-generator.py @@ -25,6 +25,7 @@ NODES = json.loads(os.environ["NODES"]) NODE_IDENTITIES = json.loads(os.getenv("NODE_IDENTITIES", "{}")) OCTEZ_SIGNERS = json.loads(os.getenv("OCTEZ_SIGNERS", "{}")) +OCTEZ_ROLLUP_NODES = json.loads(os.getenv("OCTEZ_ROLLUP_NODES", "{}")) TACOINFRA_SIGNERS = json.loads(os.getenv("TACOINFRA_SIGNERS", "{}")) MY_POD_NAME = os.environ["MY_POD_NAME"] @@ -56,6 +57,8 @@ if MY_POD_TYPE == "signing": MY_POD_CONFIG = OCTEZ_SIGNERS[MY_POD_NAME] +if MY_POD_TYPE == "rollup": + MY_POD_CONFIG = OCTEZ_ROLLUP_NODES[MY_POD_NAME] NETWORK_CONFIG = CHAIN_PARAMS["network"] @@ -337,6 +340,9 @@ def expose_secret_key(account_name): if MY_POD_TYPE == "signing": return account_name in MY_POD_CONFIG.get("accounts") + if MY_POD_TYPE == "rollup": + return account_name == MY_POD_CONFIG.get("operator_account") + if MY_POD_TYPE == "node": if MY_POD_CONFIG.get("bake_using_account", "") == account_name: return True From bbf54876720f1e129a1c46a1ab662282fb870989 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Fri, 14 Apr 2023 22:08:23 -0700 Subject: [PATCH 02/65] ensure it starts --- charts/tezos/templates/octez-rollup-node.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/charts/tezos/templates/octez-rollup-node.yaml b/charts/tezos/templates/octez-rollup-node.yaml index f3de83243..33edf9217 100644 --- a/charts/tezos/templates/octez-rollup-node.yaml +++ b/charts/tezos/templates/octez-rollup-node.yaml @@ -14,7 +14,7 @@ spec: app: {{ $.Values.smart_rollup_node_statefulset.name }} --- apiVersion: apps/v1 -kind: StatefulSet +kind: Deployment metadata: name: {{ $k }} namespace: {{ $.Release.Namespace }} @@ -62,9 +62,7 @@ spec: name: tezos-config env: - name: MY_POD_NAME - valueFrom: - fieldRef: - fieldPath: metadata.name + value: {{ $k }} - name: MY_POD_TYPE value: {{ $.Values.smart_rollup_node_statefulset.pod_type }} volumeMounts: From a538c024cb2907d74141c1f364dd0b5d9ec93bfa Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Fri, 14 Apr 2023 22:44:54 -0700 Subject: [PATCH 03/65] fix rpc endpoint --- charts/tezos/scripts/smart-rollup-node.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/charts/tezos/scripts/smart-rollup-node.sh b/charts/tezos/scripts/smart-rollup-node.sh index 54eb910da..469896ec0 100644 --- a/charts/tezos/scripts/smart-rollup-node.sh +++ b/charts/tezos/scripts/smart-rollup-node.sh @@ -6,8 +6,7 @@ CLIENT_DIR="$TEZ_VAR/client" NODE_DIR="$TEZ_VAR/node" NODE_DATA_DIR="$TEZ_VAR/node/data" -CMD="$TEZ_BIN/octez-smart-rollup-node-alpha -d $CLIENT_DIR run operator for ${ROLLUP_ADDRESS} with operators ${OPERATOR_ACCOUNT}" - +CMD="$TEZ_BIN/octez-smart-rollup-node-alpha --endpoint http://tezos-node-rpc:8732 -d $CLIENT_DIR run operator for ${ROLLUP_ADDRESS} with operators ${OPERATOR_ACCOUNT}" # ensure we can run tezos-signer commands without specifying client dir ln -s /var/tezos/client /home/tezos/.tezos-signer From ac8e37265dfb711ddfaf7b72865e24cb9bffddf5 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Wed, 3 May 2023 14:34:36 -0700 Subject: [PATCH 04/65] add bootstrap param injection --- charts/tezos/values.yaml | 9 +++++++++ test/charts/mainnet.expect.yaml | 2 ++ test/charts/mainnet2.expect.yaml | 2 ++ test/charts/private-chain.expect.yaml | 2 ++ utils/config-generator.py | 4 ++++ 5 files changed, 19 insertions(+) diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index 73a3fecc5..d7fb04841 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -521,6 +521,15 @@ protocols: # # This data is typically too large to pass it directly inside helm chart. # bootstrap_contract_urls: [] # +# # Pass additional structured data to add to parameters.json +# # This can be used to deploy smart rollup at bootstrap. +# bootstrap_parameters: +# bootstrap_smart_rollups: +# address: "sr1RYurGZtN8KNSpkMcCt9CgWeUaNkzsAfXf" +# pvm_kind: "arith" +# boot_sector: "" +# parameters_ty: "O [("prim", `String "Unit")]" +# ## Deploy an indexer with the chain. An indexer puts the chain ## contents in a database for efficient indexing. Most dapps need it. ## Supported indexers: diff --git a/test/charts/mainnet.expect.yaml b/test/charts/mainnet.expect.yaml index 17ff4fe00..407f85fdb 100644 --- a/test/charts/mainnet.expect.yaml +++ b/test/charts/mainnet.expect.yaml @@ -71,6 +71,8 @@ data: {} TACOINFRA_SIGNERS: | {} + OCTEZ_ROLLUP_NODES: | + {} --- # Source: tezos-chain/templates/static.yaml apiVersion: v1 diff --git a/test/charts/mainnet2.expect.yaml b/test/charts/mainnet2.expect.yaml index 2a405cd39..6abdfc1b0 100644 --- a/test/charts/mainnet2.expect.yaml +++ b/test/charts/mainnet2.expect.yaml @@ -118,6 +118,8 @@ data: {} TACOINFRA_SIGNERS: | {} + OCTEZ_ROLLUP_NODES: | + {} --- # Source: tezos-chain/templates/static.yaml apiVersion: v1 diff --git a/test/charts/private-chain.expect.yaml b/test/charts/private-chain.expect.yaml index 4dd1214ae..c9af73f70 100644 --- a/test/charts/private-chain.expect.yaml +++ b/test/charts/private-chain.expect.yaml @@ -214,6 +214,8 @@ data: ] } } + OCTEZ_ROLLUP_NODES: | + {} --- # Source: tezos-chain/templates/configs.yaml apiVersion: v1 diff --git a/utils/config-generator.py b/utils/config-generator.py index 6f144705f..39cde6689 100755 --- a/utils/config-generator.py +++ b/utils/config-generator.py @@ -550,6 +550,10 @@ def create_protocol_parameters_json(accounts): print(f"Injecting bootstrap contract from {url}") protocol_params["bootstrap_contracts"].append(requests.get(url).json()) + # Append any additional bootstrap params such as smart rollups, if any + if protocol_activation.get("bootstrap_parameters"): + protocol_params = { **protocol_params, **protocol_activation.get("bootstrap_parameters") } + return protocol_params From b936ecb24004c13706317bda1b249cbc66f70a88 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Thu, 4 May 2023 12:29:13 -0700 Subject: [PATCH 05/65] add an empty boot sector for now --- charts/tezos/scripts/smart-rollup-node.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/charts/tezos/scripts/smart-rollup-node.sh b/charts/tezos/scripts/smart-rollup-node.sh index 469896ec0..5d890f273 100644 --- a/charts/tezos/scripts/smart-rollup-node.sh +++ b/charts/tezos/scripts/smart-rollup-node.sh @@ -6,7 +6,8 @@ CLIENT_DIR="$TEZ_VAR/client" NODE_DIR="$TEZ_VAR/node" NODE_DATA_DIR="$TEZ_VAR/node/data" -CMD="$TEZ_BIN/octez-smart-rollup-node-alpha --endpoint http://tezos-node-rpc:8732 -d $CLIENT_DIR run operator for ${ROLLUP_ADDRESS} with operators ${OPERATOR_ACCOUNT}" +touch /var/tezos/smart-rollup-boot-sector +CMD="$TEZ_BIN/octez-smart-rollup-node-alpha --endpoint http://tezos-node-rpc:8732 -d $CLIENT_DIR run operator for ${ROLLUP_ADDRESS} with operators ${OPERATOR_ACCOUNT} --boot-sector-file /var/tezos/smart-rollup-boot-sector" # ensure we can run tezos-signer commands without specifying client dir ln -s /var/tezos/client /home/tezos/.tezos-signer From 267c75df17680810b6fc6b46ae4f766b50c84a8d Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Tue, 16 May 2023 21:03:57 -0700 Subject: [PATCH 06/65] put bootstrap rollup params that work in values.yaml example --- charts/tezos/values.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index d7fb04841..b3bf13069 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -527,8 +527,9 @@ protocols: # bootstrap_smart_rollups: # address: "sr1RYurGZtN8KNSpkMcCt9CgWeUaNkzsAfXf" # pvm_kind: "arith" -# boot_sector: "" -# parameters_ty: "O [("prim", `String "Unit")]" +# kernel: "" +# parameters_ty: +# prim: Unit # ## Deploy an indexer with the chain. An indexer puts the chain ## contents in a database for efficient indexing. Most dapps need it. From 6b2e5b0af266351c57179d29960e9683db0a568d Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Sun, 28 May 2023 10:43:06 -0700 Subject: [PATCH 07/65] fix example --- charts/tezos/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index b3bf13069..40af6d3d9 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -529,7 +529,7 @@ protocols: # pvm_kind: "arith" # kernel: "" # parameters_ty: -# prim: Unit +# prim: unit # ## Deploy an indexer with the chain. An indexer puts the chain ## contents in a database for efficient indexing. Most dapps need it. From a73a3417d9889b222d5b44f4de527a00a9941ac7 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Sun, 28 May 2023 10:55:20 -0700 Subject: [PATCH 08/65] remove leftover signer code --- charts/tezos/scripts/smart-rollup-node.sh | 2 -- charts/tezos/values.yaml | 4 ---- 2 files changed, 6 deletions(-) diff --git a/charts/tezos/scripts/smart-rollup-node.sh b/charts/tezos/scripts/smart-rollup-node.sh index 5d890f273..926f76655 100644 --- a/charts/tezos/scripts/smart-rollup-node.sh +++ b/charts/tezos/scripts/smart-rollup-node.sh @@ -8,7 +8,5 @@ NODE_DATA_DIR="$TEZ_VAR/node/data" touch /var/tezos/smart-rollup-boot-sector CMD="$TEZ_BIN/octez-smart-rollup-node-alpha --endpoint http://tezos-node-rpc:8732 -d $CLIENT_DIR run operator for ${ROLLUP_ADDRESS} with operators ${OPERATOR_ACCOUNT} --boot-sector-file /var/tezos/smart-rollup-boot-sector" -# ensure we can run tezos-signer commands without specifying client dir -ln -s /var/tezos/client /home/tezos/.tezos-signer exec $CMD diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index 40af6d3d9..86688824f 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -331,10 +331,6 @@ tacoinfraSigners: {} # # Rollup nodes # -# Define remote signers. Bakers automatically use signers in their namespace -# that are configured to sign for the accounts they are baking for. -# By default no signer is configured. -# # https://tezos.gitlab.io/user/key-management.html#signer smartRollupNodes: {} # Example: From 41ebc13928bc639d472689c2953503b85776d4d5 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Sun, 28 May 2023 12:02:09 -0700 Subject: [PATCH 09/65] add rollup ingress --- charts/tezos/templates/octez-rollup-node.yaml | 56 ++++++++++++++++--- charts/tezos/values.yaml | 15 ++++- 2 files changed, 62 insertions(+), 9 deletions(-) diff --git a/charts/tezos/templates/octez-rollup-node.yaml b/charts/tezos/templates/octez-rollup-node.yaml index 33edf9217..45f9562c2 100644 --- a/charts/tezos/templates/octez-rollup-node.yaml +++ b/charts/tezos/templates/octez-rollup-node.yaml @@ -3,32 +3,32 @@ apiVersion: v1 kind: Service metadata: - name: {{ $.Values.smart_rollup_node_statefulset.name }} + name: rollup-{{ $k }} namespace: {{ $.Release.Namespace }} spec: clusterIP: None ports: - - port: 8080 - name: web + - port: 8932 + name: rollup selector: - app: {{ $.Values.smart_rollup_node_statefulset.name }} + app: rollup-{{ $k }} --- apiVersion: apps/v1 kind: Deployment metadata: - name: {{ $k }} + name: rollup-{{ $k }} namespace: {{ $.Release.Namespace }} spec: podManagementPolicy: Parallel replicas: 1 - serviceName: {{ $.Values.smart_rollup_node_statefulset.name }} + serviceName: rollup-{{ $k }} selector: matchLabels: - app: {{ $.Values.smart_rollup_node_statefulset.name }} + app: rollup-{{ $k }} template: metadata: labels: - app: {{ $.Values.smart_rollup_node_statefulset.name }} + app: rollup-{{ $k }} spec: containers: - name: octez-smart-rollup-node @@ -79,4 +79,44 @@ spec: secret: secretName: tezos-secret --- +{{- if $v.ingress | default false }} +{{- if $v.ingress.enabled | default false }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: rollup-{{ $k }} + namespace: {{ $.Release.Namespace }} +{{- with $v.ingress.labels }} + labels: + {{- toYaml . | nindent 4 }} +{{- end }} +{{- with $v.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} +{{- end }} +spec: + ingressClassName: {{ $v.ingress.className }} + {{- if $v.ingress.tls }} + tls: + {{- range $v.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + - host: {{ $v.ingress.host }} + http: + paths: + - pathType: {{ $v.ingress.pathType }} + path: / + backend: + service: + name: rollup-{{ $k }} + port: + number: 8932 +{{- end }} +{{- end }} {{- end }} diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index 86688824f..8831766e2 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -330,8 +330,13 @@ tacoinfraSigners: {} # End Signers # # Rollup nodes +# Define Smart Rollup nodes. An operator account and rollup address +# must be provided. +# In private chains, you can create a rollup with the same address during +# activation. +# Optionally define an ingress for your rollup to be accessible from outside +# the cluster. # -# https://tezos.gitlab.io/user/key-management.html#signer smartRollupNodes: {} # Example: # ``` @@ -339,6 +344,14 @@ smartRollupNodes: {} # rollup-node-0: # operator_account: archive-baking-node-0 # rollup_address: sr1RYurGZtN8KNSpkMcCt9CgWeUaNkzsAfXf +# ingress: +# enabled: false +# host: "" +# annotations: {} +# className: "" +# labels: {} +# pathType: Prefix +# tls: [] # ``` # End Rollup Nodes From f0188843f2e51a8f29ce5ca1fb7fa5b00411ed3b Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Mon, 29 May 2023 14:14:38 -0700 Subject: [PATCH 10/65] set path type properly --- charts/tezos/templates/octez-rollup-node.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/tezos/templates/octez-rollup-node.yaml b/charts/tezos/templates/octez-rollup-node.yaml index 45f9562c2..71ac6274f 100644 --- a/charts/tezos/templates/octez-rollup-node.yaml +++ b/charts/tezos/templates/octez-rollup-node.yaml @@ -110,7 +110,7 @@ spec: - host: {{ $v.ingress.host }} http: paths: - - pathType: {{ $v.ingress.pathType }} + - pathType: Prefix path: / backend: service: From f17a9d25f0a6551073a098da180fd1aa1bc8de05 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Tue, 30 May 2023 20:12:38 -0700 Subject: [PATCH 11/65] make rollup node listen on 0.0.0.0 --- charts/tezos/scripts/smart-rollup-node.sh | 7 ++++++- charts/tezos/templates/octez-rollup-node.yaml | 12 ++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/charts/tezos/scripts/smart-rollup-node.sh b/charts/tezos/scripts/smart-rollup-node.sh index 926f76655..ae2048ae5 100644 --- a/charts/tezos/scripts/smart-rollup-node.sh +++ b/charts/tezos/scripts/smart-rollup-node.sh @@ -7,6 +7,11 @@ NODE_DIR="$TEZ_VAR/node" NODE_DATA_DIR="$TEZ_VAR/node/data" touch /var/tezos/smart-rollup-boot-sector -CMD="$TEZ_BIN/octez-smart-rollup-node-alpha --endpoint http://tezos-node-rpc:8732 -d $CLIENT_DIR run operator for ${ROLLUP_ADDRESS} with operators ${OPERATOR_ACCOUNT} --boot-sector-file /var/tezos/smart-rollup-boot-sector" +CMD="$TEZ_BIN/octez-smart-rollup-node-alpha \ + --endpoint http://tezos-node-rpc:8732 \ + -d $CLIENT_DIR \ + run operator for ${ROLLUP_ADDRESS} with operators ${OPERATOR_ACCOUNT} \ + --boot-sector-file /var/tezos/smart-rollup-boot-sector \ + --rpc-addr 0.0.0.0" exec $CMD diff --git a/charts/tezos/templates/octez-rollup-node.yaml b/charts/tezos/templates/octez-rollup-node.yaml index 71ac6274f..02057f07f 100644 --- a/charts/tezos/templates/octez-rollup-node.yaml +++ b/charts/tezos/templates/octez-rollup-node.yaml @@ -6,7 +6,7 @@ metadata: name: rollup-{{ $k }} namespace: {{ $.Release.Namespace }} spec: - clusterIP: None + type: NodePort ports: - port: 8932 name: rollup @@ -35,8 +35,8 @@ spec: image: "{{ $.Values.images.octez }}" imagePullPolicy: IfNotPresent ports: - - containerPort: 8080 - name: web + - containerPort: 8932 + name: rollup command: - /bin/sh volumeMounts: @@ -110,13 +110,13 @@ spec: - host: {{ $v.ingress.host }} http: paths: - - pathType: Prefix - path: / + - pathType: ImplementationSpecific + path: /* backend: service: name: rollup-{{ $k }} port: - number: 8932 + name: rollup {{- end }} {{- end }} {{- end }} From 7950c49389d7ee860f31d553cfc9f85f5d07bae9 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Tue, 30 May 2023 22:10:31 -0700 Subject: [PATCH 12/65] use debug container, pass boot sector of evm rollup --- charts/tezos/scripts/smart-rollup-node.sh | 2 +- charts/tezos/templates/octez-rollup-node.yaml | 2 +- charts/tezos/values.yaml | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/charts/tezos/scripts/smart-rollup-node.sh b/charts/tezos/scripts/smart-rollup-node.sh index ae2048ae5..92fdc2608 100644 --- a/charts/tezos/scripts/smart-rollup-node.sh +++ b/charts/tezos/scripts/smart-rollup-node.sh @@ -6,7 +6,7 @@ CLIENT_DIR="$TEZ_VAR/client" NODE_DIR="$TEZ_VAR/node" NODE_DATA_DIR="$TEZ_VAR/node/data" -touch /var/tezos/smart-rollup-boot-sector +xxd -ps -c 0 /usr/local/share/tezos/evm_kernel.wasm | tr -d '\n' > /var/tezos/smart-rollup-boot-sector CMD="$TEZ_BIN/octez-smart-rollup-node-alpha \ --endpoint http://tezos-node-rpc:8732 \ -d $CLIENT_DIR \ diff --git a/charts/tezos/templates/octez-rollup-node.yaml b/charts/tezos/templates/octez-rollup-node.yaml index 02057f07f..c1533d382 100644 --- a/charts/tezos/templates/octez-rollup-node.yaml +++ b/charts/tezos/templates/octez-rollup-node.yaml @@ -32,7 +32,7 @@ spec: spec: containers: - name: octez-smart-rollup-node - image: "{{ $.Values.images.octez }}" + image: "{{ $.Values.images.octez_debug }}" imagePullPolicy: IfNotPresent ports: - containerPort: 8932 diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index 8831766e2..e5067ee0a 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -9,6 +9,7 @@ is_invitation: false # Images not part of the tezos-k8s repo go here images: octez: tezos/tezos:v16.1 + octez_debug: tezos/tezos-debug:v16.1 tacoinfraRemoteSigner: ghcr.io/oxheadalpha/tacoinfra-remote-signer:0.1.0 # Images that are part of the tezos-k8s repo go here with 'dev' tag tezos_k8s_images: From d0f63b156cbf9118f0af0d516ba4d5460a9d9219 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Wed, 31 May 2023 09:13:50 -0700 Subject: [PATCH 13/65] use debug image in chain initiator to inject wasm --- charts/tezos/templates/_containers.tpl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/charts/tezos/templates/_containers.tpl b/charts/tezos/templates/_containers.tpl index 5981ad366..61f79337a 100644 --- a/charts/tezos/templates/_containers.tpl +++ b/charts/tezos/templates/_containers.tpl @@ -88,6 +88,8 @@ {{- $node_vals_images := $.node_vals.images | default dict }} {{- if eq .image "octez" }} image: "{{ or $node_vals_images.octez $.Values.images.octez }}" +{{- else if eq .image "octez_debug" }} + image: "{{ or $node_vals_images.octez_debug $.Values.images.octez_debug }}" {{- else }} image: "{{ $.Values.tezos_k8s_images.utils }}" {{- end }} @@ -211,7 +213,7 @@ {{- define "tezos.init_container.chain_initiator" }} {{- include "tezos.generic_container" (dict "root" $ "type" "chain-initiator" - "image" "octez" + "image" "octez_debug" ) | nindent 0 }} {{- end }} From 8c33ac70871e9df9b9d024ff63b4109c37ecc6a5 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Wed, 31 May 2023 09:24:37 -0700 Subject: [PATCH 14/65] make debug image work --- charts/tezos/templates/_containers.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/tezos/templates/_containers.tpl b/charts/tezos/templates/_containers.tpl index 61f79337a..66e78e8da 100644 --- a/charts/tezos/templates/_containers.tpl +++ b/charts/tezos/templates/_containers.tpl @@ -67,7 +67,7 @@ {{- $_ := set . "localvars" (eq .image "utils") }} {{- end }} {{- if not (hasKey . "run_script") }} - {{- $_ := set . "run_script" (eq .image "octez") }} + {{- $_ := set . "run_script" (or (eq .image "octez") (eq .image "octez_debug") ) }} {{- end }} {{- if not (hasKey . "script_command") }} {{- $_ := set . "script_command" .type }} From 63bca97f168550cf9764f197ab113ba02b95b479 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Wed, 31 May 2023 13:12:56 -0700 Subject: [PATCH 15/65] put hex of kernel in activation --- utils/config-generator.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/utils/config-generator.py b/utils/config-generator.py index 39cde6689..d4b92985d 100755 --- a/utils/config-generator.py +++ b/utils/config-generator.py @@ -1,4 +1,5 @@ import argparse +import binascii import collections import json import os @@ -552,6 +553,12 @@ def create_protocol_parameters_json(accounts): # Append any additional bootstrap params such as smart rollups, if any if protocol_activation.get("bootstrap_parameters"): + if protocol_activation["bootstrap_parameters"].get("boostrap_smart_rollups"): + for r, idx in protocol_activation["bootstrap_parameters"]["bootstrap_smart_rollups"]: + if "kernel_from_file" in r: + with open(r["kernel_from_file"], 'rb') as f: + protocol_activation["bootstrap_parameters"]["bootstrap_smart_rollups"][idx]["kernel"] = binascii.hexlify(f.read()) + del protocol_activation["bootstrap_parameters"]["bootstrap_smart_rollups"][idx]["kernel_from_file"] protocol_params = { **protocol_params, **protocol_activation.get("bootstrap_parameters") } return protocol_params From cd211091b674717bc226ada851019029d4704f08 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Wed, 31 May 2023 14:57:34 -0700 Subject: [PATCH 16/65] add debug statements --- utils/config-generator.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/utils/config-generator.py b/utils/config-generator.py index d4b92985d..d9bb20cbe 100755 --- a/utils/config-generator.py +++ b/utils/config-generator.py @@ -553,11 +553,17 @@ def create_protocol_parameters_json(accounts): # Append any additional bootstrap params such as smart rollups, if any if protocol_activation.get("bootstrap_parameters"): + print("DEBUG append additional bootstrap params") if protocol_activation["bootstrap_parameters"].get("boostrap_smart_rollups"): + print("DEBUG append smart rollup activation config") for r, idx in protocol_activation["bootstrap_parameters"]["bootstrap_smart_rollups"]: + print(f"DEBUG append activation config for smart rollup {idx} {r.get('address')}") if "kernel_from_file" in r: + print(f"DEBUG found kernel_from_file {r.get('kernel_from_file')}") with open(r["kernel_from_file"], 'rb') as f: + print("DEBUG injecting kernel hex into bootstrap params") protocol_activation["bootstrap_parameters"]["bootstrap_smart_rollups"][idx]["kernel"] = binascii.hexlify(f.read()) + print("DEBUG deleting kernel_from_file") del protocol_activation["bootstrap_parameters"]["bootstrap_smart_rollups"][idx]["kernel_from_file"] protocol_params = { **protocol_params, **protocol_activation.get("bootstrap_parameters") } From ae629433cc2bcfaf84d846c97fc8854bf25fc832 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Wed, 31 May 2023 15:19:20 -0700 Subject: [PATCH 17/65] fix typo --- charts/tezos/templates/activate-job.yaml | 2 +- utils/config-generator.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/tezos/templates/activate-job.yaml b/charts/tezos/templates/activate-job.yaml index a2c1060bc..579e7ebbb 100644 --- a/charts/tezos/templates/activate-job.yaml +++ b/charts/tezos/templates/activate-job.yaml @@ -13,7 +13,7 @@ spec: {{- include "tezos.init_container.chain_initiator" $ | indent 8 }} initContainers: - image: {{ .Values.tezos_k8s_images.utils }} - imagePullPolicy: IfNotPresent + imagePullPolicy: Always name: config-generator args: - config-generator diff --git a/utils/config-generator.py b/utils/config-generator.py index d9bb20cbe..94470f7b4 100755 --- a/utils/config-generator.py +++ b/utils/config-generator.py @@ -554,7 +554,7 @@ def create_protocol_parameters_json(accounts): # Append any additional bootstrap params such as smart rollups, if any if protocol_activation.get("bootstrap_parameters"): print("DEBUG append additional bootstrap params") - if protocol_activation["bootstrap_parameters"].get("boostrap_smart_rollups"): + if protocol_activation["bootstrap_parameters"].get("bootstrap_smart_rollups"): print("DEBUG append smart rollup activation config") for r, idx in protocol_activation["bootstrap_parameters"]["bootstrap_smart_rollups"]: print(f"DEBUG append activation config for smart rollup {idx} {r.get('address')}") From a0974eeb88b593c276b7739cc6dc1a19caff3897 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Wed, 31 May 2023 15:25:42 -0700 Subject: [PATCH 18/65] fix enumerate --- utils/config-generator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/config-generator.py b/utils/config-generator.py index 94470f7b4..6ccf6eda1 100755 --- a/utils/config-generator.py +++ b/utils/config-generator.py @@ -556,7 +556,7 @@ def create_protocol_parameters_json(accounts): print("DEBUG append additional bootstrap params") if protocol_activation["bootstrap_parameters"].get("bootstrap_smart_rollups"): print("DEBUG append smart rollup activation config") - for r, idx in protocol_activation["bootstrap_parameters"]["bootstrap_smart_rollups"]: + for idx, r in enumerate(protocol_activation["bootstrap_parameters"]["bootstrap_smart_rollups"]): print(f"DEBUG append activation config for smart rollup {idx} {r.get('address')}") if "kernel_from_file" in r: print(f"DEBUG found kernel_from_file {r.get('kernel_from_file')}") From 5f9848629a77c00f1ad854d62cc3001f4f0ddba7 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Wed, 31 May 2023 15:51:21 -0700 Subject: [PATCH 19/65] revert config gen changes as the rollup is not in utils container --- charts/tezos/scripts/chain-initiator.sh | 26 +++++++++++++++++++++++++ utils/config-generator.py | 13 ------------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/charts/tezos/scripts/chain-initiator.sh b/charts/tezos/scripts/chain-initiator.sh index d26fbbaf8..25f9bf7ae 100644 --- a/charts/tezos/scripts/chain-initiator.sh +++ b/charts/tezos/scripts/chain-initiator.sh @@ -11,6 +11,32 @@ if ! $CLIENT rpc get /chains/main/blocks/head/header | grep '"level": 0,'; then exit 0 fi +PARAMS_FILE='/etc/tezos/parameters.json' + +# Check if there are any bootstrap rollups. If present, replace the file with its content. +size=$(jq '.bootstrap_parameters.bootstrap_smart_rollups | length' $PARAMS_FILE) + +# Iterate over each object in the bootstrap_smart_rollups array +for (( i=0; i<$size; i++ )) +do + KERNEL_FILE=$(jq -r ".bootstrap_parameters.bootstrap_smart_rollups[$i].kernel_from_file" $PARAMS_FILE) + + # Check if file exists + if [ ! -f "$KERNEL_FILE" ]; then + echo "Kernel file $KERNEL_FILE not found!" + exit 1 + fi + + # Convert the file content to hex + HEX_KERNEL=$(xxd -ps -c 256 $KERNEL_FILE | tr -d '\n') + + # Replace kernel_from_file with kernel in JSON, and write to a temporary file + jq --arg kernel "$HEX_KERNEL" ".bootstrap_parameters.bootstrap_smart_rollups[$i] |= del(.kernel_from_file) | .bootstrap_parameters.bootstrap_smart_rollups[$i] += {\"kernel\": \$kernel}" $PARAMS_FILE > temp.json + + # Move the temporary file back to the original file + mv temp.json $PARAMS_FILE +done + echo Activating chain: $CLIENT -d /var/tezos/client --block \ genesis activate protocol \ diff --git a/utils/config-generator.py b/utils/config-generator.py index 6ccf6eda1..39cde6689 100755 --- a/utils/config-generator.py +++ b/utils/config-generator.py @@ -1,5 +1,4 @@ import argparse -import binascii import collections import json import os @@ -553,18 +552,6 @@ def create_protocol_parameters_json(accounts): # Append any additional bootstrap params such as smart rollups, if any if protocol_activation.get("bootstrap_parameters"): - print("DEBUG append additional bootstrap params") - if protocol_activation["bootstrap_parameters"].get("bootstrap_smart_rollups"): - print("DEBUG append smart rollup activation config") - for idx, r in enumerate(protocol_activation["bootstrap_parameters"]["bootstrap_smart_rollups"]): - print(f"DEBUG append activation config for smart rollup {idx} {r.get('address')}") - if "kernel_from_file" in r: - print(f"DEBUG found kernel_from_file {r.get('kernel_from_file')}") - with open(r["kernel_from_file"], 'rb') as f: - print("DEBUG injecting kernel hex into bootstrap params") - protocol_activation["bootstrap_parameters"]["bootstrap_smart_rollups"][idx]["kernel"] = binascii.hexlify(f.read()) - print("DEBUG deleting kernel_from_file") - del protocol_activation["bootstrap_parameters"]["bootstrap_smart_rollups"][idx]["kernel_from_file"] protocol_params = { **protocol_params, **protocol_activation.get("bootstrap_parameters") } return protocol_params From 6893519a6f26051e1986c7d9b9bd51cf1b3dd2b0 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Wed, 31 May 2023 19:58:48 -0700 Subject: [PATCH 20/65] add a function to replace file with its content in hex --- charts/tezos/scripts/chain-initiator.sh | 84 ++++++++++++++++++++----- 1 file changed, 67 insertions(+), 17 deletions(-) diff --git a/charts/tezos/scripts/chain-initiator.sh b/charts/tezos/scripts/chain-initiator.sh index 25f9bf7ae..f51b12b6a 100644 --- a/charts/tezos/scripts/chain-initiator.sh +++ b/charts/tezos/scripts/chain-initiator.sh @@ -1,46 +1,96 @@ CLIENT="/usr/local/bin/octez-client --endpoint http://tezos-node-rpc:8732" +echo "LALAL" until $CLIENT rpc get /chains/main/blocks/head/header | grep '"level":'; do sleep 2 done -set -x set -o pipefail if ! $CLIENT rpc get /chains/main/blocks/head/header | grep '"level": 0,'; then echo "Chain already activated, considering activation successful and exiting" exit 0 fi -PARAMS_FILE='/etc/tezos/parameters.json' +# Substitute #fromfile with the hex encoded files in question. +# This is for bootstrapped smart rollups. -# Check if there are any bootstrap rollups. If present, replace the file with its content. -size=$(jq '.bootstrap_parameters.bootstrap_smart_rollups | length' $PARAMS_FILE) -# Iterate over each object in the bootstrap_smart_rollups array -for (( i=0; i<$size; i++ )) + +PARAMETERS_FILE='/etc/tezos/parameters.json' +TMP_PARAMETERS_FILE='/etc/tezos/tmp_parameters.json' + +# Pattern to search for +pattern='fromfile#' + +# Buffer for characters +buffer='' + +# Whether 'fromfile#' was detected +detected_fromfile=false + +# Process each character +while IFS= read -r -n1 char do - KERNEL_FILE=$(jq -r ".bootstrap_parameters.bootstrap_smart_rollups[$i].kernel_from_file" $PARAMS_FILE) + # Add the character to the buffer + buffer=$(printf "%s%s" "$buffer" "$char") + + # If the buffer ends with the pattern + if [ "${buffer%"$pattern"}" != "$buffer" ] + then + detected_fromfile=true + + # Clear the buffer + buffer='' + + # Read the filename + filename='' + while IFS= read -r -n1 char && [ "$char" != '"' ] + do + filename=$(printf "%s%s" "$filename" "$char") + done + + echo "Found kernel file: $filename" # Check if file exists - if [ ! -f "$KERNEL_FILE" ]; then - echo "Kernel file $KERNEL_FILE not found!" + if [ ! -f "$filename" ]; then + echo "Kernel file $filename not found!" exit 1 fi - # Convert the file content to hex - HEX_KERNEL=$(xxd -ps -c 256 $KERNEL_FILE | tr -d '\n') + # Convert the file content to hex and append to the temp file + xxd -ps -c 256 "$filename" | tr -d '\n' >> $TMP_PARAMETERS_FILE - # Replace kernel_from_file with kernel in JSON, and write to a temporary file - jq --arg kernel "$HEX_KERNEL" ".bootstrap_parameters.bootstrap_smart_rollups[$i] |= del(.kernel_from_file) | .bootstrap_parameters.bootstrap_smart_rollups[$i] += {\"kernel\": \$kernel}" $PARAMS_FILE > temp.json + # Add a closing double quote + printf '"' >> $TMP_PARAMETERS_FILE + elif [ ${#buffer} -ge ${#pattern} ] + then + # Write the oldest character in the buffer to the temporary file + printf "%s" "${buffer%"${buffer#?}"}" >> $TMP_PARAMETERS_FILE - # Move the temporary file back to the original file - mv temp.json $PARAMS_FILE -done + # Remove the oldest character from the buffer + buffer=${buffer#?} + fi +done < "$PARAMETERS_FILE" +# If there's anything left in the buffer, write it to the file +if [ -n "$buffer" ] +then + printf "%s" "$buffer" >> $TMP_PARAMETERS_FILE +fi + +# Replace the original parameters.json file with the modified one only if 'fromfile#' was detected +if $detected_fromfile; then + mv $TMP_PARAMETERS_FILE $PARAMETERS_FILE + echo "Updated JSON saved in '$PARAMETERS_FILE'" +else + rm -f $TMP_PARAMETERS_FILE + echo "No 'fromfile#' detected in '$PARAMETERS_FILE', no changes made." +fi echo Activating chain: $CLIENT -d /var/tezos/client --block \ genesis activate protocol \ {{ .Values.activation.protocol_hash }} \ with fitness 1 and key \ $( cat /etc/tezos/activation_account_name ) \ - and parameters /etc/tezos/parameters.json 2>&1 | head -200 + and parameters $PARAMETERS_FILE 2>&1 | head -200 +sleep 10000 From be0747988d43699f189e8b9e0a9fa4499ea92e24 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Wed, 31 May 2023 20:02:27 -0700 Subject: [PATCH 21/65] remove sleep --- charts/tezos/scripts/chain-initiator.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/charts/tezos/scripts/chain-initiator.sh b/charts/tezos/scripts/chain-initiator.sh index f51b12b6a..f8158846f 100644 --- a/charts/tezos/scripts/chain-initiator.sh +++ b/charts/tezos/scripts/chain-initiator.sh @@ -1,5 +1,4 @@ CLIENT="/usr/local/bin/octez-client --endpoint http://tezos-node-rpc:8732" -echo "LALAL" until $CLIENT rpc get /chains/main/blocks/head/header | grep '"level":'; do sleep 2 @@ -93,4 +92,3 @@ $CLIENT -d /var/tezos/client --block \ with fitness 1 and key \ $( cat /etc/tezos/activation_account_name ) \ and parameters $PARAMETERS_FILE 2>&1 | head -200 -sleep 10000 From 9a769db79f368e79082a6392512792cf860a91a9 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Wed, 31 May 2023 20:57:58 -0700 Subject: [PATCH 22/65] add evm proxy --- charts/tezos/templates/octez-rollup-node.yaml | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/charts/tezos/templates/octez-rollup-node.yaml b/charts/tezos/templates/octez-rollup-node.yaml index c1533d382..c8507fd54 100644 --- a/charts/tezos/templates/octez-rollup-node.yaml +++ b/charts/tezos/templates/octez-rollup-node.yaml @@ -15,6 +15,39 @@ spec: --- apiVersion: apps/v1 kind: Deployment +metadata: + name: evm-proxy-{{ $k }} + namespace: {{ $.Release.Namespace }} +spec: + podManagementPolicy: Parallel + replicas: 1 + serviceName: evm-proxy-{{ $k }} + selector: + matchLabels: + app: evm-proxy-{{ $k }} + template: + metadata: + labels: + app: evm-proxy-{{ $k }} + spec: + containers: + - name: octez-evm-proxy + image: "{{ $.Values.images.octez }}" + imagePullPolicy: IfNotPresent + ports: + - containerPort: 8545 + name: evm-proxy + command: + - /bin/sh + args: + - "-c" + - | +{{ tpl ($.Files.Get "scripts/evm-proxy.sh") $ | indent 12 }} + securityContext: + fsGroup: 1000 +--- +apiVersion: apps/v1 +kind: Deployment metadata: name: rollup-{{ $k }} namespace: {{ $.Release.Namespace }} From ecc6c276a7948be9206e4980c66b6a0006501572 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Wed, 31 May 2023 21:08:08 -0700 Subject: [PATCH 23/65] add evm proxy script --- charts/tezos/scripts/evm-proxy.sh | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 charts/tezos/scripts/evm-proxy.sh diff --git a/charts/tezos/scripts/evm-proxy.sh b/charts/tezos/scripts/evm-proxy.sh new file mode 100644 index 000000000..ca34019de --- /dev/null +++ b/charts/tezos/scripts/evm-proxy.sh @@ -0,0 +1,7 @@ +set -ex + +TEZ_BIN=/usr/local/bin + +CMD="$TEZ_BIN/octez-evm-proxy-server" + +exec $CMD From 6c1a232ff79e403d34edcaa575d505b72d1ad628 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Wed, 31 May 2023 21:21:32 -0700 Subject: [PATCH 24/65] add "run" to evm-proxy cmd --- charts/tezos/scripts/evm-proxy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/tezos/scripts/evm-proxy.sh b/charts/tezos/scripts/evm-proxy.sh index ca34019de..aa3e97cec 100644 --- a/charts/tezos/scripts/evm-proxy.sh +++ b/charts/tezos/scripts/evm-proxy.sh @@ -2,6 +2,6 @@ set -ex TEZ_BIN=/usr/local/bin -CMD="$TEZ_BIN/octez-evm-proxy-server" +CMD="$TEZ_BIN/octez-evm-proxy-server run" exec $CMD From c14f56db70ff8202fd3339201238b018a42f9a97 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Wed, 31 May 2023 22:15:48 -0700 Subject: [PATCH 25/65] add evm proxy service --- charts/tezos/templates/octez-rollup-node.yaml | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/charts/tezos/templates/octez-rollup-node.yaml b/charts/tezos/templates/octez-rollup-node.yaml index c8507fd54..3f4578835 100644 --- a/charts/tezos/templates/octez-rollup-node.yaml +++ b/charts/tezos/templates/octez-rollup-node.yaml @@ -3,15 +3,15 @@ apiVersion: v1 kind: Service metadata: - name: rollup-{{ $k }} + name: evm-proxy-{{ $k }} namespace: {{ $.Release.Namespace }} spec: type: NodePort ports: - - port: 8932 - name: rollup + - port: 8545 + name: evm-proxy selector: - app: rollup-{{ $k }} + app: evm-proxy-{{ $k }} --- apiVersion: apps/v1 kind: Deployment @@ -46,6 +46,19 @@ spec: securityContext: fsGroup: 1000 --- +apiVersion: v1 +kind: Service +metadata: + name: rollup-{{ $k }} + namespace: {{ $.Release.Namespace }} +spec: + type: NodePort + ports: + - port: 8932 + name: rollup + selector: + app: rollup-{{ $k }} +--- apiVersion: apps/v1 kind: Deployment metadata: From eecc09b21d09489a9ffe6c9426bed46b2a92c3c3 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Thu, 1 Jun 2023 09:31:39 -0700 Subject: [PATCH 26/65] add ingress for evm proxy --- charts/tezos/scripts/evm-proxy.sh | 4 +- charts/tezos/templates/octez-rollup-node.yaml | 41 +++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/charts/tezos/scripts/evm-proxy.sh b/charts/tezos/scripts/evm-proxy.sh index aa3e97cec..68d448683 100644 --- a/charts/tezos/scripts/evm-proxy.sh +++ b/charts/tezos/scripts/evm-proxy.sh @@ -2,6 +2,8 @@ set -ex TEZ_BIN=/usr/local/bin -CMD="$TEZ_BIN/octez-evm-proxy-server run" +CMD="$TEZ_BIN/octez-evm-proxy-server run \ + --rpc-addr 0.0.0.0 \ + --rollup-node-endpoint http://rollup-evm:8932" exec $CMD diff --git a/charts/tezos/templates/octez-rollup-node.yaml b/charts/tezos/templates/octez-rollup-node.yaml index 3f4578835..a5d3cabdd 100644 --- a/charts/tezos/templates/octez-rollup-node.yaml +++ b/charts/tezos/templates/octez-rollup-node.yaml @@ -46,6 +46,47 @@ spec: securityContext: fsGroup: 1000 --- +{{- if $v.evm_proxy_ingress | default false }} +{{- if $v.evm_proxy_ingress.enabled | default false }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: evm-proxy-{{ $k }} + namespace: {{ $.Release.Namespace }} +{{- with $v.evm_proxy_ingress.labels }} + labels: + {{- toYaml . | nindent 4 }} +{{- end }} +{{- with $v.evm_proxy_ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} +{{- end }} +spec: + ingressClassName: {{ $v.evm_proxy_ingress.className }} + {{- if $v.evm_proxy_ingress.tls }} + tls: + {{- range $v.evm_proxy_ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + - host: {{ $v.evm_proxy_ingress.host }} + http: + paths: + - pathType: ImplementationSpecific + path: /* + backend: + service: + name: evm-proxy-{{ $k }} + port: + name: evm-proxy +{{- end }} +{{- end }} +--- apiVersion: v1 kind: Service metadata: From 1fe5e8a6f36f8a1550e2d7d35684e52b845283e2 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Wed, 7 Jun 2023 14:22:12 -0700 Subject: [PATCH 27/65] add comment to chain-initiator --- charts/tezos/scripts/chain-initiator.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/charts/tezos/scripts/chain-initiator.sh b/charts/tezos/scripts/chain-initiator.sh index f8158846f..0c367170d 100644 --- a/charts/tezos/scripts/chain-initiator.sh +++ b/charts/tezos/scripts/chain-initiator.sh @@ -13,7 +13,8 @@ fi # Substitute #fromfile with the hex encoded files in question. # This is for bootstrapped smart rollups. - +# Note that this is low-level string substitution with `read` +# Due to the size of the hex-encoded kernel, using `sed` was not possible. PARAMETERS_FILE='/etc/tezos/parameters.json' TMP_PARAMETERS_FILE='/etc/tezos/tmp_parameters.json' From 23d3d255957180000e1b3197dc31591122d6c6c2 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Wed, 7 Jun 2023 16:53:34 -0700 Subject: [PATCH 28/65] add persistent data dir for rollup node --- charts/tezos/scripts/smart-rollup-node.sh | 4 ++-- charts/tezos/templates/octez-rollup-node.yaml | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/charts/tezos/scripts/smart-rollup-node.sh b/charts/tezos/scripts/smart-rollup-node.sh index 92fdc2608..29ee3daae 100644 --- a/charts/tezos/scripts/smart-rollup-node.sh +++ b/charts/tezos/scripts/smart-rollup-node.sh @@ -3,14 +3,14 @@ set -ex TEZ_VAR=/var/tezos TEZ_BIN=/usr/local/bin CLIENT_DIR="$TEZ_VAR/client" -NODE_DIR="$TEZ_VAR/node" -NODE_DATA_DIR="$TEZ_VAR/node/data" +ROLLUP_DATA_DIR="$TEZ_VAR/rollup" xxd -ps -c 0 /usr/local/share/tezos/evm_kernel.wasm | tr -d '\n' > /var/tezos/smart-rollup-boot-sector CMD="$TEZ_BIN/octez-smart-rollup-node-alpha \ --endpoint http://tezos-node-rpc:8732 \ -d $CLIENT_DIR \ run operator for ${ROLLUP_ADDRESS} with operators ${OPERATOR_ACCOUNT} \ + --data-dir ${ROLLUP_DATA_DIR} \ --boot-sector-file /var/tezos/smart-rollup-boot-sector \ --rpc-addr 0.0.0.0" diff --git a/charts/tezos/templates/octez-rollup-node.yaml b/charts/tezos/templates/octez-rollup-node.yaml index a5d3cabdd..816856079 100644 --- a/charts/tezos/templates/octez-rollup-node.yaml +++ b/charts/tezos/templates/octez-rollup-node.yaml @@ -101,7 +101,7 @@ spec: app: rollup-{{ $k }} --- apiVersion: apps/v1 -kind: Deployment +kind: StatefulSet metadata: name: rollup-{{ $k }} namespace: {{ $.Release.Namespace }} @@ -160,11 +160,20 @@ spec: securityContext: fsGroup: 1000 volumes: - - emptyDir: {} + - volume: var-volume name: var-volume - name: tezos-accounts secret: secretName: tezos-secret + volumeClaimTemplates: + - metadata: + name: var-volume + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: "15Gi" --- {{- if $v.ingress | default false }} {{- if $v.ingress.enabled | default false }} From b48dd976bde2ae5c4c906a02cc9ce7587fc7e602 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Thu, 8 Jun 2023 08:39:31 -0700 Subject: [PATCH 29/65] support several evm rollups --- charts/tezos/scripts/evm-proxy.sh | 2 +- charts/tezos/templates/octez-rollup-node.yaml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/charts/tezos/scripts/evm-proxy.sh b/charts/tezos/scripts/evm-proxy.sh index 68d448683..ab80c51d3 100644 --- a/charts/tezos/scripts/evm-proxy.sh +++ b/charts/tezos/scripts/evm-proxy.sh @@ -4,6 +4,6 @@ TEZ_BIN=/usr/local/bin CMD="$TEZ_BIN/octez-evm-proxy-server run \ --rpc-addr 0.0.0.0 \ - --rollup-node-endpoint http://rollup-evm:8932" + --rollup-node-endpoint http://rollup-${MY_POD_NAME}:8932" exec $CMD diff --git a/charts/tezos/templates/octez-rollup-node.yaml b/charts/tezos/templates/octez-rollup-node.yaml index 816856079..8dd2471ab 100644 --- a/charts/tezos/templates/octez-rollup-node.yaml +++ b/charts/tezos/templates/octez-rollup-node.yaml @@ -43,6 +43,9 @@ spec: - "-c" - | {{ tpl ($.Files.Get "scripts/evm-proxy.sh") $ | indent 12 }} + env: + - name: MY_POD_NAME + value: {{ $k }} securityContext: fsGroup: 1000 --- From 2c84253dbd76f54a69996a7672f0f5ff961ec3a4 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Fri, 9 Jun 2023 10:09:23 -0700 Subject: [PATCH 30/65] fix path type for nginx --- charts/tezos/templates/octez-rollup-node.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/charts/tezos/templates/octez-rollup-node.yaml b/charts/tezos/templates/octez-rollup-node.yaml index 8dd2471ab..e7dcdf7b6 100644 --- a/charts/tezos/templates/octez-rollup-node.yaml +++ b/charts/tezos/templates/octez-rollup-node.yaml @@ -80,8 +80,8 @@ spec: - host: {{ $v.evm_proxy_ingress.host }} http: paths: - - pathType: ImplementationSpecific - path: /* + - pathType: Prefix + path: / backend: service: name: evm-proxy-{{ $k }} @@ -209,8 +209,8 @@ spec: - host: {{ $v.ingress.host }} http: paths: - - pathType: ImplementationSpecific - path: /* + - pathType: Prefix + path: / backend: service: name: rollup-{{ $k }} From cfbaa3023fb15a20ea56ed253032eea24ce52c32 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Fri, 9 Jun 2023 16:47:30 -0700 Subject: [PATCH 31/65] DAL initial --- charts/tezos/scripts/dal-node.sh | 18 +++ charts/tezos/templates/octez-dal-node.yaml | 129 +++++++++++++++++++++ charts/tezos/values.yaml | 2 + 3 files changed, 149 insertions(+) create mode 100644 charts/tezos/scripts/dal-node.sh create mode 100644 charts/tezos/templates/octez-dal-node.yaml diff --git a/charts/tezos/scripts/dal-node.sh b/charts/tezos/scripts/dal-node.sh new file mode 100644 index 000000000..120fe4f1c --- /dev/null +++ b/charts/tezos/scripts/dal-node.sh @@ -0,0 +1,18 @@ +set -ex + +TEZ_VAR=/var/tezos +TEZ_BIN=/usr/local/bin +DAL_DATA_DIR="$TEZ_VAR/dal" + +mkdir -p ${DAL_DATA_DIR} +$TEZ_BIN/octez-dal-node \ + init-config \ + --data-dir ${DAL_DATA_DIR} \ + --rpc-addr 0.0.0.0 + +CMD="$TEZ_BIN/octez-dal-node \ + --endpoint http://tezos-node-rpc:8732 \ + run \ + --data-dir ${DAL_DATA_DIR}" + +exec $CMD diff --git a/charts/tezos/templates/octez-dal-node.yaml b/charts/tezos/templates/octez-dal-node.yaml new file mode 100644 index 000000000..a39f57269 --- /dev/null +++ b/charts/tezos/templates/octez-dal-node.yaml @@ -0,0 +1,129 @@ +{{- range $k, $v := .Values.dalNodes }} + +apiVersion: v1 +kind: Service +metadata: + name: dal-{{ $k }} + namespace: {{ $.Release.Namespace }} +spec: + type: NodePort + ports: + - port: 8932 + name: dal + selector: + app: dal-{{ $k }} +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: dal-{{ $k }} + namespace: {{ $.Release.Namespace }} +spec: + podManagementPolicy: Parallel + replicas: 1 + serviceName: dal-{{ $k }} + selector: + matchLabels: + app: dal-{{ $k }} + template: + metadata: + labels: + app: dal-{{ $k }} + spec: + containers: + - name: octez-dal-node + image: "{{ $.Values.images.octez }}" + imagePullPolicy: IfNotPresent + ports: + - containerPort: 8932 + name: dal + command: + - /bin/sh + volumeMounts: + - mountPath: /var/tezos + name: var-volume + args: + - "-c" + - | +{{ tpl ($.Files.Get "scripts/dal-node.sh") $ | indent 12 }} + env: + - name: dal_ADDRESS + value: {{ $v.dal_address }} + - name: OPERATOR_ACCOUNT + value: {{ $v.operator_account }} + initContainers: + # - image: {{ $.Values.tezos_k8s_images.utils }} + # imagePullPolicy: IfNotPresent + # name: config-generator + # args: + # - "config-generator" + # envFrom: + # - configMapRef: + # name: tezos-config + # env: + # - name: MY_POD_NAME + # value: {{ $k }} + # volumeMounts: + # - mountPath: /var/tezos + # name: var-volume + # - mountPath: /etc/secret-volume + # name: tezos-accounts + # securityContext: + # fsGroup: 1000 + # volumes: + # - volume: var-volume + # name: var-volume + # - name: tezos-accounts + # secret: + # secretName: tezos-secret + volumeClaimTemplates: + - metadata: + name: var-volume + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: "15Gi" +--- +{{- if $v.ingress | default false }} +{{- if $v.ingress.enabled | default false }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: dal-{{ $k }} + namespace: {{ $.Release.Namespace }} +{{- with $v.ingress.labels }} + labels: + {{- toYaml . | nindent 4 }} +{{- end }} +{{- with $v.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} +{{- end }} +spec: + ingressClassName: {{ $v.ingress.className }} + {{- if $v.ingress.tls }} + tls: + {{- range $v.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + - host: {{ $v.ingress.host }} + http: + paths: + - pathType: Prefix + path: / + backend: + service: + name: dal-{{ $k }} + port: + name: dal +{{- end }} +{{- end }} +{{- end }} diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index e5067ee0a..f24ff2a9b 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -355,6 +355,8 @@ smartRollupNodes: {} # tls: [] # ``` +dalNodes: {} + # End Rollup Nodes # When spinning up nodes, tezos-k8s will attempt to download a snapshot from a From d5f8ebdaf8d92e2438f2452b45cc5f9ed4b4e788 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Fri, 9 Jun 2023 17:15:00 -0700 Subject: [PATCH 32/65] add service ports --- charts/tezos/scripts/dal-node.sh | 4 ++- charts/tezos/templates/octez-dal-node.yaml | 31 +++------------------- 2 files changed, 7 insertions(+), 28 deletions(-) diff --git a/charts/tezos/scripts/dal-node.sh b/charts/tezos/scripts/dal-node.sh index 120fe4f1c..3ba909883 100644 --- a/charts/tezos/scripts/dal-node.sh +++ b/charts/tezos/scripts/dal-node.sh @@ -8,7 +8,9 @@ mkdir -p ${DAL_DATA_DIR} $TEZ_BIN/octez-dal-node \ init-config \ --data-dir ${DAL_DATA_DIR} \ - --rpc-addr 0.0.0.0 + --net-addr 0.0.0.0:11732 \ + --rpc-addr 0.0.0.0 \ + --rpc-port 10732 CMD="$TEZ_BIN/octez-dal-node \ --endpoint http://tezos-node-rpc:8732 \ diff --git a/charts/tezos/templates/octez-dal-node.yaml b/charts/tezos/templates/octez-dal-node.yaml index a39f57269..6b1999a94 100644 --- a/charts/tezos/templates/octez-dal-node.yaml +++ b/charts/tezos/templates/octez-dal-node.yaml @@ -35,8 +35,10 @@ spec: image: "{{ $.Values.images.octez }}" imagePullPolicy: IfNotPresent ports: - - containerPort: 8932 - name: dal + - containerPort: 10732 + name: rpc + - containerPort: 11732 + name: p2p command: - /bin/sh volumeMounts: @@ -51,31 +53,6 @@ spec: value: {{ $v.dal_address }} - name: OPERATOR_ACCOUNT value: {{ $v.operator_account }} - initContainers: - # - image: {{ $.Values.tezos_k8s_images.utils }} - # imagePullPolicy: IfNotPresent - # name: config-generator - # args: - # - "config-generator" - # envFrom: - # - configMapRef: - # name: tezos-config - # env: - # - name: MY_POD_NAME - # value: {{ $k }} - # volumeMounts: - # - mountPath: /var/tezos - # name: var-volume - # - mountPath: /etc/secret-volume - # name: tezos-accounts - # securityContext: - # fsGroup: 1000 - # volumes: - # - volume: var-volume - # name: var-volume - # - name: tezos-accounts - # secret: - # secretName: tezos-secret volumeClaimTemplates: - metadata: name: var-volume From 8a2d0ab689a485e75d8aa4b37ed5cb44fc5dd94c Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Sun, 11 Jun 2023 17:38:21 -0700 Subject: [PATCH 33/65] new syntax for evm proxy --- charts/tezos/scripts/evm-proxy.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/tezos/scripts/evm-proxy.sh b/charts/tezos/scripts/evm-proxy.sh index ab80c51d3..d37f70b1c 100644 --- a/charts/tezos/scripts/evm-proxy.sh +++ b/charts/tezos/scripts/evm-proxy.sh @@ -3,7 +3,7 @@ set -ex TEZ_BIN=/usr/local/bin CMD="$TEZ_BIN/octez-evm-proxy-server run \ - --rpc-addr 0.0.0.0 \ - --rollup-node-endpoint http://rollup-${MY_POD_NAME}:8932" + with endpoint http://rollup-${MY_POD_NAME}:8932 \ + --rpc-addr 0.0.0.0" exec $CMD From 28f8187503504be0bd62de9aa8e726b4fae543be Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Sun, 11 Jun 2023 22:26:01 -0700 Subject: [PATCH 34/65] fix ports, remove wrong DAL vars --- charts/tezos/templates/octez-dal-node.yaml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/charts/tezos/templates/octez-dal-node.yaml b/charts/tezos/templates/octez-dal-node.yaml index 6b1999a94..b44e82aa1 100644 --- a/charts/tezos/templates/octez-dal-node.yaml +++ b/charts/tezos/templates/octez-dal-node.yaml @@ -8,8 +8,10 @@ metadata: spec: type: NodePort ports: - - port: 8932 - name: dal + - port: 10732 + name: rpc + - port: 11732 + name: p2p selector: app: dal-{{ $k }} --- @@ -48,11 +50,6 @@ spec: - "-c" - | {{ tpl ($.Files.Get "scripts/dal-node.sh") $ | indent 12 }} - env: - - name: dal_ADDRESS - value: {{ $v.dal_address }} - - name: OPERATOR_ACCOUNT - value: {{ $v.operator_account }} volumeClaimTemplates: - metadata: name: var-volume @@ -100,7 +97,7 @@ spec: service: name: dal-{{ $k }} port: - name: dal + name: rpc {{- end }} {{- end }} {{- end }} From 3d2e62e87da88084fcec834f458781a92c79be63 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Sun, 11 Jun 2023 23:09:50 -0700 Subject: [PATCH 35/65] DAL permissions fix --- charts/tezos/templates/octez-dal-node.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/charts/tezos/templates/octez-dal-node.yaml b/charts/tezos/templates/octez-dal-node.yaml index b44e82aa1..733881d40 100644 --- a/charts/tezos/templates/octez-dal-node.yaml +++ b/charts/tezos/templates/octez-dal-node.yaml @@ -50,6 +50,8 @@ spec: - "-c" - | {{ tpl ($.Files.Get "scripts/dal-node.sh") $ | indent 12 }} + securityContext: + fsGroup: 1000 volumeClaimTemplates: - metadata: name: var-volume From aa5e27d1f279308770e7c6d29cc3d51071092769 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Sun, 11 Jun 2023 23:33:26 -0700 Subject: [PATCH 36/65] DAL: use unsafe SRS in config-init --- charts/tezos/scripts/dal-node.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/charts/tezos/scripts/dal-node.sh b/charts/tezos/scripts/dal-node.sh index 3ba909883..5fbaaf43b 100644 --- a/charts/tezos/scripts/dal-node.sh +++ b/charts/tezos/scripts/dal-node.sh @@ -10,7 +10,8 @@ $TEZ_BIN/octez-dal-node \ --data-dir ${DAL_DATA_DIR} \ --net-addr 0.0.0.0:11732 \ --rpc-addr 0.0.0.0 \ - --rpc-port 10732 + --rpc-port 10732 \ + --use-unsafe-srs-for-tests CMD="$TEZ_BIN/octez-dal-node \ --endpoint http://tezos-node-rpc:8732 \ From ffda22e7f632613b013b1ba8f8e1d93204e5cfce Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Thu, 15 Jun 2023 09:04:01 -0700 Subject: [PATCH 37/65] dal node new syntax --- charts/tezos/scripts/dal-node.sh | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/charts/tezos/scripts/dal-node.sh b/charts/tezos/scripts/dal-node.sh index 5fbaaf43b..60ac8a7bc 100644 --- a/charts/tezos/scripts/dal-node.sh +++ b/charts/tezos/scripts/dal-node.sh @@ -5,17 +5,13 @@ TEZ_BIN=/usr/local/bin DAL_DATA_DIR="$TEZ_VAR/dal" mkdir -p ${DAL_DATA_DIR} -$TEZ_BIN/octez-dal-node \ - init-config \ - --data-dir ${DAL_DATA_DIR} \ - --net-addr 0.0.0.0:11732 \ - --rpc-addr 0.0.0.0 \ - --rpc-port 10732 \ - --use-unsafe-srs-for-tests CMD="$TEZ_BIN/octez-dal-node \ - --endpoint http://tezos-node-rpc:8732 \ run \ - --data-dir ${DAL_DATA_DIR}" + --data-dir ${DAL_DATA_DIR} \ + --endpoint http://tezos-node-rpc:8732 \ + --net-addr 0.0.0.0:11732 \ + --rpc-addr 0.0.0.0:10732 \ + --use-unsafe-srs-for-tests" exec $CMD From fa9299cfe2e10f9b5371c5a3b001fa3866f24392 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Tue, 20 Jun 2023 11:25:40 -0700 Subject: [PATCH 38/65] add ability for the baker to pick a DAL node --- charts/tezos/scripts/baker.sh | 4 ++++ charts/tezos/templates/configs.yaml | 3 +++ charts/tezos/values.yaml | 3 +++ 3 files changed, 10 insertions(+) diff --git a/charts/tezos/scripts/baker.sh b/charts/tezos/scripts/baker.sh index c1f97de9f..7a415ed1a 100644 --- a/charts/tezos/scripts/baker.sh +++ b/charts/tezos/scripts/baker.sh @@ -37,6 +37,10 @@ if [ -f /etc/tezos/baker-config/${my_baker_account}_operations_pool ]; then extra_args="${extra_args} --operations-pool $(cat /etc/tezos/baker-config/${my_baker_account}_operations_pool)" fi +if [ -f /etc/tezos/baker-config/${my_baker_account}_dal_node ]; then + extra_args="${extra_args} --dal-node $(cat /etc/tezos/baker-config/${my_baker_account}_dal_node)" +fi + CLIENT="$TEZ_BIN/octez-client -d $CLIENT_DIR" CMD="$TEZ_BIN/octez-baker-$proto_command -d $CLIENT_DIR" diff --git a/charts/tezos/templates/configs.yaml b/charts/tezos/templates/configs.yaml index 38bfadd9f..cd8743430 100644 --- a/charts/tezos/templates/configs.yaml +++ b/charts/tezos/templates/configs.yaml @@ -100,6 +100,9 @@ data: {{- if $v.operations_pool }} {{ $k }}_operations_pool: {{ $v.operations_pool | quote }} {{- end }} +{{- if $v.dal_node }} + {{ $k }}_dal_node: {{ $v.dal_node | quote }} +{{- end }} {{- end }} kind: ConfigMap metadata: diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index 4781fce76..8d25e263f 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -58,6 +58,8 @@ accounts: {} # mempool queries when baking a block. This is useful to run a Flashbake-capable baker. # The entry is passed to baker binaries using the `--operations-pool` flag. # +# The `dal_node` field instructs the baker to target a url for a DAL node. +# # - Public chains: Accounts do not get `is_bootstrap_baker_account` and # `bootstrap_balance` fields. # - Non-public chains: If you don't specify accounts needed by nodes, they can @@ -79,6 +81,7 @@ accounts: {} # baker1: # key: edsk... # operations_pool: http://flashbake-endpoint-baker-listener:12732 +# dal_node: http://dal_node:10732 # protocols: # - command: PtMumbai # vote: From 811d6c6047543383d06f752fb3bdf3b587c7edf1 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Tue, 20 Jun 2023 12:58:41 -0700 Subject: [PATCH 39/65] remove debug container workaround - evm rollup is now in main container --- charts/tezos/templates/_containers.tpl | 6 ++---- charts/tezos/templates/octez-rollup-node.yaml | 2 +- charts/tezos/values.yaml | 1 - 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/charts/tezos/templates/_containers.tpl b/charts/tezos/templates/_containers.tpl index 65c0a9972..1be4ced1f 100644 --- a/charts/tezos/templates/_containers.tpl +++ b/charts/tezos/templates/_containers.tpl @@ -67,7 +67,7 @@ {{- $_ := set . "localvars" (eq .image "utils") }} {{- end }} {{- if not (hasKey . "run_script") }} - {{- $_ := set . "run_script" (or (eq .image "octez") (eq .image "octez_debug") ) }} + {{- $_ := set . "run_script" (eq .image "octez") }} {{- end }} {{- if not (hasKey . "script_command") }} {{- $_ := set . "script_command" .type }} @@ -88,8 +88,6 @@ {{- $node_vals_images := $.node_vals.images | default dict }} {{- if eq .image "octez" }} image: "{{ or $node_vals_images.octez $.Values.images.octez }}" -{{- else if eq .image "octez_debug" }} - image: "{{ or $node_vals_images.octez_debug $.Values.images.octez_debug }}" {{- else }} image: "{{ $.Values.tezos_k8s_images.utils }}" {{- end }} @@ -213,7 +211,7 @@ {{- define "tezos.init_container.chain_initiator" }} {{- include "tezos.generic_container" (dict "root" $ "type" "chain-initiator" - "image" "octez_debug" + "image" "octez" ) | nindent 0 }} {{- end }} diff --git a/charts/tezos/templates/octez-rollup-node.yaml b/charts/tezos/templates/octez-rollup-node.yaml index e7dcdf7b6..f86d6fd24 100644 --- a/charts/tezos/templates/octez-rollup-node.yaml +++ b/charts/tezos/templates/octez-rollup-node.yaml @@ -122,7 +122,7 @@ spec: spec: containers: - name: octez-smart-rollup-node - image: "{{ $.Values.images.octez_debug }}" + image: "{{ $.Values.images.octez }}" imagePullPolicy: IfNotPresent ports: - containerPort: 8932 diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index 8d25e263f..ad397fbb6 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -9,7 +9,6 @@ is_invitation: false # Images not part of the tezos-k8s repo go here images: octez: tezos/tezos:v16.1 - octez_debug: tezos/tezos-debug:v16.1 tacoinfraRemoteSigner: ghcr.io/oxheadalpha/tacoinfra-remote-signer:0.1.0 # Images that are part of the tezos-k8s repo go here with 'dev' tag tezos_k8s_images: From 892d955a27ad2e31d9f69d984cfa093d1fcdde64 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Thu, 22 Jun 2023 11:30:20 -0700 Subject: [PATCH 40/65] new EVM rollup model: installer kernel + small files --- charts/tezos/scripts/smart-rollup-node.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/charts/tezos/scripts/smart-rollup-node.sh b/charts/tezos/scripts/smart-rollup-node.sh index 29ee3daae..db08565af 100644 --- a/charts/tezos/scripts/smart-rollup-node.sh +++ b/charts/tezos/scripts/smart-rollup-node.sh @@ -4,8 +4,11 @@ TEZ_VAR=/var/tezos TEZ_BIN=/usr/local/bin CLIENT_DIR="$TEZ_VAR/client" ROLLUP_DATA_DIR="$TEZ_VAR/rollup" +ROLLUP_DATA_DIR_PREIMAGES="$ROLLUP_DATA_DIR/wasm_2_0_0" -xxd -ps -c 0 /usr/local/share/tezos/evm_kernel.wasm | tr -d '\n' > /var/tezos/smart-rollup-boot-sector +xxd -ps -c 0 /usr/local/share/tezos/evm_kernel/evm_installer.wasm | tr -d '\n' > /var/tezos/smart-rollup-boot-sector +mkdir -p "$ROLLUP_DATA_DIR_PREIMAGES" +cp /usr/local/share/tezos/evm_kernel/* "$ROLLUP_DATA_DIR_PREIMAGES" CMD="$TEZ_BIN/octez-smart-rollup-node-alpha \ --endpoint http://tezos-node-rpc:8732 \ -d $CLIENT_DIR \ From 9839dc7e03682bd131f79d38ca0d7010e4eb3057 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Thu, 22 Jun 2023 12:19:24 -0700 Subject: [PATCH 41/65] remove usafe srs param --- charts/tezos/scripts/dal-node.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/charts/tezos/scripts/dal-node.sh b/charts/tezos/scripts/dal-node.sh index 60ac8a7bc..ae6012042 100644 --- a/charts/tezos/scripts/dal-node.sh +++ b/charts/tezos/scripts/dal-node.sh @@ -11,7 +11,6 @@ CMD="$TEZ_BIN/octez-dal-node \ --data-dir ${DAL_DATA_DIR} \ --endpoint http://tezos-node-rpc:8732 \ --net-addr 0.0.0.0:11732 \ - --rpc-addr 0.0.0.0:10732 \ - --use-unsafe-srs-for-tests" + --rpc-addr 0.0.0.0:10732" exec $CMD From a5a20c55737104fc45d6eb184d098ccccc08de4b Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Thu, 22 Jun 2023 21:10:28 -0700 Subject: [PATCH 42/65] fix xxd command --- charts/tezos/scripts/smart-rollup-node.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/tezos/scripts/smart-rollup-node.sh b/charts/tezos/scripts/smart-rollup-node.sh index db08565af..9ef78a7da 100644 --- a/charts/tezos/scripts/smart-rollup-node.sh +++ b/charts/tezos/scripts/smart-rollup-node.sh @@ -6,7 +6,7 @@ CLIENT_DIR="$TEZ_VAR/client" ROLLUP_DATA_DIR="$TEZ_VAR/rollup" ROLLUP_DATA_DIR_PREIMAGES="$ROLLUP_DATA_DIR/wasm_2_0_0" -xxd -ps -c 0 /usr/local/share/tezos/evm_kernel/evm_installer.wasm | tr -d '\n' > /var/tezos/smart-rollup-boot-sector +xxd -p -c 0 /usr/local/share/tezos/evm_kernel/evm_installer.wasm | tr -d '\n' > /var/tezos/smart-rollup-boot-sector mkdir -p "$ROLLUP_DATA_DIR_PREIMAGES" cp /usr/local/share/tezos/evm_kernel/* "$ROLLUP_DATA_DIR_PREIMAGES" CMD="$TEZ_BIN/octez-smart-rollup-node-alpha \ From 7308c140dd0f9838ef89d1f3ee2a7049357c0233 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Sun, 25 Jun 2023 22:39:46 -0700 Subject: [PATCH 43/65] fix xxd in activation script as well --- charts/tezos/scripts/chain-initiator.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/tezos/scripts/chain-initiator.sh b/charts/tezos/scripts/chain-initiator.sh index 0c367170d..e5512211d 100644 --- a/charts/tezos/scripts/chain-initiator.sh +++ b/charts/tezos/scripts/chain-initiator.sh @@ -58,7 +58,7 @@ do fi # Convert the file content to hex and append to the temp file - xxd -ps -c 256 "$filename" | tr -d '\n' >> $TMP_PARAMETERS_FILE + xxd -p -c 0 "$filename" | tr -d '\n' >> $TMP_PARAMETERS_FILE # Add a closing double quote printf '"' >> $TMP_PARAMETERS_FILE From 3b6d07b7d439213bcb4ca41ca6eb95a081858bf4 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Mon, 26 Jun 2023 11:01:47 -0700 Subject: [PATCH 44/65] set -e: fail activation when a command fails --- charts/tezos/scripts/chain-initiator.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/charts/tezos/scripts/chain-initiator.sh b/charts/tezos/scripts/chain-initiator.sh index e5512211d..5f9a2b2e8 100644 --- a/charts/tezos/scripts/chain-initiator.sh +++ b/charts/tezos/scripts/chain-initiator.sh @@ -1,3 +1,4 @@ +set -e CLIENT="/usr/local/bin/octez-client --endpoint http://tezos-node-rpc:8732" until $CLIENT rpc get /chains/main/blocks/head/header | grep '"level":'; do From bf877fb3f008304f6daf9c19cd979afe3f73bbe7 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Fri, 28 Jul 2023 14:03:09 -0700 Subject: [PATCH 45/65] support for bootstrap profile in DAL --- charts/tezos/scripts/dal-node.sh | 7 +++++++ charts/tezos/templates/octez-dal-node.yaml | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/charts/tezos/scripts/dal-node.sh b/charts/tezos/scripts/dal-node.sh index ae6012042..115e22430 100644 --- a/charts/tezos/scripts/dal-node.sh +++ b/charts/tezos/scripts/dal-node.sh @@ -6,8 +6,15 @@ DAL_DATA_DIR="$TEZ_VAR/dal" mkdir -p ${DAL_DATA_DIR} +extra_args="" +if [ ${BOOTSTRAP_PROFILE} == "true" ]; then + extra_args="--bootstrap-profile" +fi + + CMD="$TEZ_BIN/octez-dal-node \ run \ + ${extra_args} \ --data-dir ${DAL_DATA_DIR} \ --endpoint http://tezos-node-rpc:8732 \ --net-addr 0.0.0.0:11732 \ diff --git a/charts/tezos/templates/octez-dal-node.yaml b/charts/tezos/templates/octez-dal-node.yaml index 733881d40..9af78d1e0 100644 --- a/charts/tezos/templates/octez-dal-node.yaml +++ b/charts/tezos/templates/octez-dal-node.yaml @@ -50,6 +50,13 @@ spec: - "-c" - | {{ tpl ($.Files.Get "scripts/dal-node.sh") $ | indent 12 }} +{{- if $v | default false }} +{{- if $v.bootstrapProfile | default false }} + env: + - name: BOOTSTRAP_PROFILE + value: "true" +{{- end }} +{{- end }} securityContext: fsGroup: 1000 volumeClaimTemplates: @@ -62,6 +69,7 @@ spec: requests: storage: "15Gi" --- +{{- if $v | default false }} {{- if $v.ingress | default false }} {{- if $v.ingress.enabled | default false }} apiVersion: networking.k8s.io/v1 @@ -103,3 +111,4 @@ spec: {{- end }} {{- end }} {{- end }} +{{- end }} From cecb9057dbb3726bb88541ca62093c6db8aa1bec Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Fri, 28 Jul 2023 15:10:21 -0700 Subject: [PATCH 46/65] fix newlines in dal script --- charts/tezos/scripts/dal-node.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/charts/tezos/scripts/dal-node.sh b/charts/tezos/scripts/dal-node.sh index 115e22430..6a96c3809 100644 --- a/charts/tezos/scripts/dal-node.sh +++ b/charts/tezos/scripts/dal-node.sh @@ -12,10 +12,7 @@ if [ ${BOOTSTRAP_PROFILE} == "true" ]; then fi -CMD="$TEZ_BIN/octez-dal-node \ - run \ - ${extra_args} \ - --data-dir ${DAL_DATA_DIR} \ +CMD="$TEZ_BIN/octez-dal-node run ${extra_args} --data-dir ${DAL_DATA_DIR} \ --endpoint http://tezos-node-rpc:8732 \ --net-addr 0.0.0.0:11732 \ --rpc-addr 0.0.0.0:10732" From 3e749f322d8a7aa472d5166fed5f6be6365bb7da Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Thu, 14 Sep 2023 12:10:07 -0700 Subject: [PATCH 47/65] switch to --mode dev on evm proxy --- charts/tezos/scripts/evm-proxy.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/charts/tezos/scripts/evm-proxy.sh b/charts/tezos/scripts/evm-proxy.sh index d37f70b1c..2fa8f9fb0 100644 --- a/charts/tezos/scripts/evm-proxy.sh +++ b/charts/tezos/scripts/evm-proxy.sh @@ -4,6 +4,7 @@ TEZ_BIN=/usr/local/bin CMD="$TEZ_BIN/octez-evm-proxy-server run \ with endpoint http://rollup-${MY_POD_NAME}:8932 \ + --mode dev \ --rpc-addr 0.0.0.0" exec $CMD From 945e698f4170b1f8a02848c353adee2e7260ff5f Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Sun, 17 Sep 2023 19:30:58 -0700 Subject: [PATCH 48/65] switch to universal smart rollup node (instead of proto-dependent) --- charts/tezos/scripts/smart-rollup-node.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/tezos/scripts/smart-rollup-node.sh b/charts/tezos/scripts/smart-rollup-node.sh index 9ef78a7da..0df3d4861 100644 --- a/charts/tezos/scripts/smart-rollup-node.sh +++ b/charts/tezos/scripts/smart-rollup-node.sh @@ -9,7 +9,7 @@ ROLLUP_DATA_DIR_PREIMAGES="$ROLLUP_DATA_DIR/wasm_2_0_0" xxd -p -c 0 /usr/local/share/tezos/evm_kernel/evm_installer.wasm | tr -d '\n' > /var/tezos/smart-rollup-boot-sector mkdir -p "$ROLLUP_DATA_DIR_PREIMAGES" cp /usr/local/share/tezos/evm_kernel/* "$ROLLUP_DATA_DIR_PREIMAGES" -CMD="$TEZ_BIN/octez-smart-rollup-node-alpha \ +CMD="$TEZ_BIN/octez-smart-rollup-node \ --endpoint http://tezos-node-rpc:8732 \ -d $CLIENT_DIR \ run operator for ${ROLLUP_ADDRESS} with operators ${OPERATOR_ACCOUNT} \ From 5db2e150a6cf93714df5595c3f912e47e1013c8e Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Wed, 27 Sep 2023 19:18:54 -0700 Subject: [PATCH 49/65] ensure you can add annotations to your evm proxy and evm node --- charts/tezos/templates/octez-rollup-node.yaml | 30 ++++++++++++++----- charts/tezos/values.yaml | 13 ++++++++ 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/charts/tezos/templates/octez-rollup-node.yaml b/charts/tezos/templates/octez-rollup-node.yaml index f86d6fd24..74cac8520 100644 --- a/charts/tezos/templates/octez-rollup-node.yaml +++ b/charts/tezos/templates/octez-rollup-node.yaml @@ -1,5 +1,6 @@ {{- range $k, $v := .Values.smartRollupNodes }} +{{- if $v.evm_proxy | default false }} apiVersion: v1 kind: Service metadata: @@ -18,6 +19,12 @@ kind: Deployment metadata: name: evm-proxy-{{ $k }} namespace: {{ $.Release.Namespace }} +{{- if $v.evm_proxy.annotations | default false }} +{{- with $v.annotations }} + annotations: + {{- toYaml . | nindent 4 }} +{{- end }} +{{- end }} spec: podManagementPolicy: Parallel replicas: 1 @@ -49,26 +56,26 @@ spec: securityContext: fsGroup: 1000 --- -{{- if $v.evm_proxy_ingress | default false }} -{{- if $v.evm_proxy_ingress.enabled | default false }} +{{- if $v.evm_proxy.ingress | default false }} +{{- if $v.evm_proxy.ingress.enabled | default false }} apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: evm-proxy-{{ $k }} namespace: {{ $.Release.Namespace }} -{{- with $v.evm_proxy_ingress.labels }} +{{- with $v.evm_proxy.ingress.labels }} labels: {{- toYaml . | nindent 4 }} {{- end }} -{{- with $v.evm_proxy_ingress.annotations }} +{{- with $v.evm_proxy.ingress.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} spec: - ingressClassName: {{ $v.evm_proxy_ingress.className }} - {{- if $v.evm_proxy_ingress.tls }} + ingressClassName: {{ $v.evm_proxy.ingress.className }} + {{- if $v.evm_proxy.ingress.tls }} tls: - {{- range $v.evm_proxy_ingress.tls }} + {{- range $v.evm_proxy.ingress.tls }} - hosts: {{- range .hosts }} - {{ . | quote }} @@ -77,7 +84,7 @@ spec: {{- end }} {{- end }} rules: - - host: {{ $v.evm_proxy_ingress.host }} + - host: {{ $v.evm_proxy.ingress.host }} http: paths: - pathType: Prefix @@ -89,6 +96,7 @@ spec: name: evm-proxy {{- end }} {{- end }} +{{- end }} --- apiVersion: v1 kind: Service @@ -108,6 +116,12 @@ kind: StatefulSet metadata: name: rollup-{{ $k }} namespace: {{ $.Release.Namespace }} +{{- if $v.annotations | default false }} +{{- with $v.annotations }} + annotations: + {{- toYaml . | nindent 4 }} +{{- end }} +{{- end }} spec: podManagementPolicy: Parallel replicas: 1 diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index ad397fbb6..ef8e93cd4 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -342,6 +342,8 @@ tacoinfraSigners: {} # activation. # Optionally define an ingress for your rollup to be accessible from outside # the cluster. +# If your rollup is an EVM rollup, you can also define an EVM proxy object, +# which can in turn have an ingress. # smartRollupNodes: {} # Example: @@ -350,6 +352,7 @@ smartRollupNodes: {} # rollup-node-0: # operator_account: archive-baking-node-0 # rollup_address: sr1RYurGZtN8KNSpkMcCt9CgWeUaNkzsAfXf +# annotations: {} # ingress: # enabled: false # host: "" @@ -358,6 +361,16 @@ smartRollupNodes: {} # labels: {} # pathType: Prefix # tls: [] +# evm_proxy: +# annotations: {} +# ingress: +# enabled: false +# host: "" +# annotations: {} +# className: "" +# labels: {} +# pathType: Prefix +# tls: [] # ``` dalNodes: {} From a79d5893f66d42ab4b67179d5aa366bbdf334373 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Thu, 28 Sep 2023 21:20:14 -0700 Subject: [PATCH 50/65] proper match for annotation --- charts/tezos/templates/octez-rollup-node.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/tezos/templates/octez-rollup-node.yaml b/charts/tezos/templates/octez-rollup-node.yaml index 74cac8520..870e6bb3f 100644 --- a/charts/tezos/templates/octez-rollup-node.yaml +++ b/charts/tezos/templates/octez-rollup-node.yaml @@ -20,7 +20,7 @@ metadata: name: evm-proxy-{{ $k }} namespace: {{ $.Release.Namespace }} {{- if $v.evm_proxy.annotations | default false }} -{{- with $v.annotations }} +{{- with $v.evm_proxy.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} From abcef9f775e320fa5085dd8bea7d1b56546b4353 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Tue, 10 Oct 2023 00:00:09 -0700 Subject: [PATCH 51/65] add option to pass public IP to dal nodes --- charts/tezos/scripts/dal-node.sh | 6 ++++-- charts/tezos/templates/octez-dal-node.yaml | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/charts/tezos/scripts/dal-node.sh b/charts/tezos/scripts/dal-node.sh index 6a96c3809..9de88fe07 100644 --- a/charts/tezos/scripts/dal-node.sh +++ b/charts/tezos/scripts/dal-node.sh @@ -7,10 +7,12 @@ DAL_DATA_DIR="$TEZ_VAR/dal" mkdir -p ${DAL_DATA_DIR} extra_args="" -if [ ${BOOTSTRAP_PROFILE} == "true" ]; then +if [ "${BOOTSTRAP_PROFILE}" == "true" ]; then extra_args="--bootstrap-profile" fi - +if [ "${PUBLIC_ADDR}" != "" ]; then + extra_args="${extra_args} --public-addr ${PUBLIC_ADDR}" +fi CMD="$TEZ_BIN/octez-dal-node run ${extra_args} --data-dir ${DAL_DATA_DIR} \ --endpoint http://tezos-node-rpc:8732 \ diff --git a/charts/tezos/templates/octez-dal-node.yaml b/charts/tezos/templates/octez-dal-node.yaml index 9af78d1e0..49e3b4f54 100644 --- a/charts/tezos/templates/octez-dal-node.yaml +++ b/charts/tezos/templates/octez-dal-node.yaml @@ -51,11 +51,15 @@ spec: - | {{ tpl ($.Files.Get "scripts/dal-node.sh") $ | indent 12 }} {{- if $v | default false }} -{{- if $v.bootstrapProfile | default false }} env: +{{- if $v.bootstrapProfile | default false }} - name: BOOTSTRAP_PROFILE value: "true" {{- end }} +{{- if $v.publicAddr | default false }} + - name: PUBLIC_ADDR + value: "{{ $v.publicAddr }}" +{{- end }} {{- end }} securityContext: fsGroup: 1000 From 4c8766e344ecc0e2bb865266891e649902ebaa31 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Tue, 10 Oct 2023 10:11:04 -0700 Subject: [PATCH 52/65] add ability to pass attester profiles to DAL node --- charts/tezos/scripts/dal-node.sh | 3 +++ charts/tezos/templates/octez-dal-node.yaml | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/charts/tezos/scripts/dal-node.sh b/charts/tezos/scripts/dal-node.sh index 9de88fe07..721de67b1 100644 --- a/charts/tezos/scripts/dal-node.sh +++ b/charts/tezos/scripts/dal-node.sh @@ -10,6 +10,9 @@ extra_args="" if [ "${BOOTSTRAP_PROFILE}" == "true" ]; then extra_args="--bootstrap-profile" fi +if [ "${ATTESTER_PROFILES}" != "" ]; then + extra_args="${extra_args} --attester-profiles ${ATTESTER_PROFILES}" +fi if [ "${PUBLIC_ADDR}" != "" ]; then extra_args="${extra_args} --public-addr ${PUBLIC_ADDR}" fi diff --git a/charts/tezos/templates/octez-dal-node.yaml b/charts/tezos/templates/octez-dal-node.yaml index 49e3b4f54..458e5712a 100644 --- a/charts/tezos/templates/octez-dal-node.yaml +++ b/charts/tezos/templates/octez-dal-node.yaml @@ -56,6 +56,10 @@ spec: - name: BOOTSTRAP_PROFILE value: "true" {{- end }} +{{- if $v.attesterProfiles | default false }} + - name: ATTESTER_PROFILES + value: "{{ $v.attesterProfiles }}" +{{- end }} {{- if $v.publicAddr | default false }} - name: PUBLIC_ADDR value: "{{ $v.publicAddr }}" From bd10f3387f513ee39c0209f602717cc5f0842a62 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Tue, 10 Oct 2023 11:00:05 -0700 Subject: [PATCH 53/65] dal: add ability to specify peer --- charts/tezos/scripts/dal-node.sh | 3 +++ charts/tezos/templates/octez-dal-node.yaml | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/charts/tezos/scripts/dal-node.sh b/charts/tezos/scripts/dal-node.sh index 721de67b1..c2a9a1210 100644 --- a/charts/tezos/scripts/dal-node.sh +++ b/charts/tezos/scripts/dal-node.sh @@ -13,6 +13,9 @@ fi if [ "${ATTESTER_PROFILES}" != "" ]; then extra_args="${extra_args} --attester-profiles ${ATTESTER_PROFILES}" fi +if [ "${PEER}" != "" ]; then + extra_args="${extra_args} --peer ${PEER}" +fi if [ "${PUBLIC_ADDR}" != "" ]; then extra_args="${extra_args} --public-addr ${PUBLIC_ADDR}" fi diff --git a/charts/tezos/templates/octez-dal-node.yaml b/charts/tezos/templates/octez-dal-node.yaml index 458e5712a..34a4f05ef 100644 --- a/charts/tezos/templates/octez-dal-node.yaml +++ b/charts/tezos/templates/octez-dal-node.yaml @@ -60,6 +60,10 @@ spec: - name: ATTESTER_PROFILES value: "{{ $v.attesterProfiles }}" {{- end }} +{{- if $v.peer | default false }} + - name: PEER + value: "{{ $v.peer }}" +{{- end }} {{- if $v.publicAddr | default false }} - name: PUBLIC_ADDR value: "{{ $v.publicAddr }}" From ea864f006c578b4526ab4cfd7d7a72f8de0acde8 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Tue, 31 Oct 2023 08:43:30 -0700 Subject: [PATCH 54/65] new evm proxy CLI --- charts/tezos/scripts/evm-proxy.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/charts/tezos/scripts/evm-proxy.sh b/charts/tezos/scripts/evm-proxy.sh index 2fa8f9fb0..004d18d1c 100644 --- a/charts/tezos/scripts/evm-proxy.sh +++ b/charts/tezos/scripts/evm-proxy.sh @@ -2,9 +2,17 @@ set -ex TEZ_BIN=/usr/local/bin -CMD="$TEZ_BIN/octez-evm-proxy-server run \ - with endpoint http://rollup-${MY_POD_NAME}:8932 \ - --mode dev \ - --rpc-addr 0.0.0.0" +if ls /usr/local/bin/octez-evm-node; then + CMD="$TEZ_BIN/octez-evm-node run proxy \ + with endpoint http://rollup-${MY_POD_NAME}:8932 \ + --mode dev \ + --rpc-addr 0.0.0.0" +else + # temporary until 20231106 mondaynet - old command + CMD="$TEZ_BIN/octez-evm-proxy-server run \ + with endpoint http://rollup-${MY_POD_NAME}:8932 \ + --mode dev \ + --rpc-addr 0.0.0.0" +fi exec $CMD From 191040e463354acb9033a5ca337caa95f5777bcb Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Tue, 31 Oct 2023 08:46:51 -0700 Subject: [PATCH 55/65] actually mondaynet doesn't have evm rollup --- charts/tezos/scripts/evm-proxy.sh | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/charts/tezos/scripts/evm-proxy.sh b/charts/tezos/scripts/evm-proxy.sh index 004d18d1c..c4c286705 100644 --- a/charts/tezos/scripts/evm-proxy.sh +++ b/charts/tezos/scripts/evm-proxy.sh @@ -2,17 +2,9 @@ set -ex TEZ_BIN=/usr/local/bin -if ls /usr/local/bin/octez-evm-node; then - CMD="$TEZ_BIN/octez-evm-node run proxy \ - with endpoint http://rollup-${MY_POD_NAME}:8932 \ - --mode dev \ - --rpc-addr 0.0.0.0" -else - # temporary until 20231106 mondaynet - old command - CMD="$TEZ_BIN/octez-evm-proxy-server run \ - with endpoint http://rollup-${MY_POD_NAME}:8932 \ - --mode dev \ - --rpc-addr 0.0.0.0" -fi +CMD="$TEZ_BIN/octez-evm-node run proxy \ + with endpoint http://rollup-${MY_POD_NAME}:8932 \ + --mode dev \ + --rpc-addr 0.0.0.0" exec $CMD From 197c8c92e04e35e3704c92e84a0aad54e3d138c4 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Tue, 31 Oct 2023 20:55:50 -0700 Subject: [PATCH 56/65] remove --mode dev for evm proxy --- charts/tezos/scripts/evm-proxy.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/charts/tezos/scripts/evm-proxy.sh b/charts/tezos/scripts/evm-proxy.sh index c4c286705..bbe4c1756 100644 --- a/charts/tezos/scripts/evm-proxy.sh +++ b/charts/tezos/scripts/evm-proxy.sh @@ -4,7 +4,6 @@ TEZ_BIN=/usr/local/bin CMD="$TEZ_BIN/octez-evm-node run proxy \ with endpoint http://rollup-${MY_POD_NAME}:8932 \ - --mode dev \ --rpc-addr 0.0.0.0" exec $CMD From f69fc07dfd64d76a1441547f1e16a6a65ff614d8 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Thu, 2 Nov 2023 09:56:47 -0700 Subject: [PATCH 57/65] put evm proxy in dev mode again --- charts/tezos/scripts/evm-proxy.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/charts/tezos/scripts/evm-proxy.sh b/charts/tezos/scripts/evm-proxy.sh index bbe4c1756..44d873507 100644 --- a/charts/tezos/scripts/evm-proxy.sh +++ b/charts/tezos/scripts/evm-proxy.sh @@ -4,6 +4,7 @@ TEZ_BIN=/usr/local/bin CMD="$TEZ_BIN/octez-evm-node run proxy \ with endpoint http://rollup-${MY_POD_NAME}:8932 \ + --version dev \ --rpc-addr 0.0.0.0" exec $CMD From 4f7f5e6951b16396d27f26b1476197a3dcdbe1ab Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Wed, 15 Nov 2023 07:11:09 -0800 Subject: [PATCH 58/65] replace `--version dev` with `--devmode` --- charts/tezos/scripts/evm-proxy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/tezos/scripts/evm-proxy.sh b/charts/tezos/scripts/evm-proxy.sh index 44d873507..a62c08896 100644 --- a/charts/tezos/scripts/evm-proxy.sh +++ b/charts/tezos/scripts/evm-proxy.sh @@ -4,7 +4,7 @@ TEZ_BIN=/usr/local/bin CMD="$TEZ_BIN/octez-evm-node run proxy \ with endpoint http://rollup-${MY_POD_NAME}:8932 \ - --version dev \ + --devmode \ --rpc-addr 0.0.0.0" exec $CMD From 59a1fc9b1fc41ad6ffd0888a85de194e8f4c0991 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Thu, 23 Nov 2023 12:07:31 -0800 Subject: [PATCH 59/65] fix disappearing ingress issue --- charts/tezos/templates/octez-dal-node.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/charts/tezos/templates/octez-dal-node.yaml b/charts/tezos/templates/octez-dal-node.yaml index 34a4f05ef..5477ba4fe 100644 --- a/charts/tezos/templates/octez-dal-node.yaml +++ b/charts/tezos/templates/octez-dal-node.yaml @@ -120,6 +120,7 @@ spec: name: dal-{{ $k }} port: name: rpc +--- {{- end }} {{- end }} {{- end }} From 20b75645fc19fd411d2e835fca5d968d6096cc42 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Sat, 2 Dec 2023 20:16:07 -0800 Subject: [PATCH 60/65] DAL update to 50Gi --- charts/tezos/templates/octez-dal-node.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/tezos/templates/octez-dal-node.yaml b/charts/tezos/templates/octez-dal-node.yaml index 5477ba4fe..2ad9811be 100644 --- a/charts/tezos/templates/octez-dal-node.yaml +++ b/charts/tezos/templates/octez-dal-node.yaml @@ -79,7 +79,7 @@ spec: - ReadWriteOnce resources: requests: - storage: "15Gi" + storage: "50Gi" --- {{- if $v | default false }} {{- if $v.ingress | default false }} From 230e93d044e5880f61002aa0c3df1d5f35911135 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Fri, 8 Dec 2023 15:10:02 -0800 Subject: [PATCH 61/65] DAL comments --- charts/tezos/values.yaml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index dc27e4f01..5c0700d6e 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -382,10 +382,19 @@ smartRollupNodes: {} # tls: [] # ``` -dalNodes: {} - # End Rollup Nodes +# DAL Nodes +dalNodes: {} +# Deploys DAL nodes in pods and maps them to L1 nodes. +# Example: +# bootstrap: +# bootstrapProfile: true +# ingress: +# # ingress details filled up by pulumi +# dal1: +# attesterProfiles: tz1foXHgRzdYdaLgX6XhpZGxbBv42LZ6ubvE + # When spinning up nodes, tezos-k8s will attempt to download a snapshot from a # known source. This should be a url to a json metadata file in the format # xtz-shots uses. If you want to sync from scratch or for a private chain, set From 8377099d46943416a1c297304bd10f969e6c5212 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Fri, 8 Dec 2023 16:51:26 -0800 Subject: [PATCH 62/65] optional hardcoded identity for DAL nodes --- charts/tezos/scripts/dal-node.sh | 7 +++++++ charts/tezos/templates/octez-dal-node.yaml | 4 ++++ charts/tezos/values.yaml | 19 +++++++++++++++---- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/charts/tezos/scripts/dal-node.sh b/charts/tezos/scripts/dal-node.sh index c2a9a1210..31155068f 100644 --- a/charts/tezos/scripts/dal-node.sh +++ b/charts/tezos/scripts/dal-node.sh @@ -19,6 +19,13 @@ fi if [ "${PUBLIC_ADDR}" != "" ]; then extra_args="${extra_args} --public-addr ${PUBLIC_ADDR}" fi +# populate identity, if provided +if [ -n "$IDENTITY_JSON" ]; then + identity_path=/var/tezos/dal/identity.json + printf "Found persistent identity, writing to $identity_path" + echo "$IDENTITY_JSON" > $identity_path +fi +# CMD="$TEZ_BIN/octez-dal-node run ${extra_args} --data-dir ${DAL_DATA_DIR} \ --endpoint http://tezos-node-rpc:8732 \ diff --git a/charts/tezos/templates/octez-dal-node.yaml b/charts/tezos/templates/octez-dal-node.yaml index 2ad9811be..f8711c8f5 100644 --- a/charts/tezos/templates/octez-dal-node.yaml +++ b/charts/tezos/templates/octez-dal-node.yaml @@ -68,6 +68,10 @@ spec: - name: PUBLIC_ADDR value: "{{ $v.publicAddr }}" {{- end }} +{{- if $v.identity | default false }} + - name: IDENTITY_JSON + value: {{ toJson $v.identity | quote }} +{{- end }} {{- end }} securityContext: fsGroup: 1000 diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index 5c0700d6e..2cf1fe020 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -180,9 +180,8 @@ should_generate_unsafe_deterministic_data: false # statefulset level. # - `is_bootstrap_node`: Boolean for is this node a bootstrap peer. # - `identity`: An optional map containing a pre-generated Tezos node -# identity. This is useful for local storage nodes which would -# need to generate an identity at every boot. The identity file -# will be created at /var/tezos/node/data/identity.json. +# identity. The identity file will be created at +# /var/tezos/node/data/identity.json. # Required fields are `peer_id`, `public_key`, `secret_key`, # and `proof_of_work_timestamp`. # @@ -391,7 +390,19 @@ dalNodes: {} # bootstrap: # bootstrapProfile: true # ingress: -# # ingress details filled up by pulumi +# enabled: false +# host: "" +# annotations: {} +# className: "" +# labels: {} +# pathType: Prefix +# tls: [] +# identity: +# # fill here the identity of the node, if you want it to persist +# peer_id: +# public_key: +# secret_key: +# proof_of_work_stamp: # dal1: # attesterProfiles: tz1foXHgRzdYdaLgX6XhpZGxbBv42LZ6ubvE From 4ea8e526064e68c87e0d4d77a6d68d10757b7c43 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Fri, 8 Dec 2023 17:25:56 -0800 Subject: [PATCH 63/65] add ability to set storage size of dal nodes in values.yaml --- charts/tezos/templates/octez-dal-node.yaml | 4 ++++ charts/tezos/values.yaml | 1 + 2 files changed, 5 insertions(+) diff --git a/charts/tezos/templates/octez-dal-node.yaml b/charts/tezos/templates/octez-dal-node.yaml index f8711c8f5..8ea4803b5 100644 --- a/charts/tezos/templates/octez-dal-node.yaml +++ b/charts/tezos/templates/octez-dal-node.yaml @@ -83,7 +83,11 @@ spec: - ReadWriteOnce resources: requests: +{{- if $v.storageSize | default false }} + storage: "{{ $v.storageSize }}" +{{- else }} storage: "50Gi" +{{- end }} --- {{- if $v | default false }} {{- if $v.ingress | default false }} diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index 2cf1fe020..7376512c6 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -404,6 +404,7 @@ dalNodes: {} # secret_key: # proof_of_work_stamp: # dal1: +# storageSize: 50Gi # attesterProfiles: tz1foXHgRzdYdaLgX6XhpZGxbBv42LZ6ubvE # When spinning up nodes, tezos-k8s will attempt to download a snapshot from a From 5d18e9d3a4f8f74e1aeb889d60cfa12a99bda932 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Sat, 9 Dec 2023 14:59:51 -0800 Subject: [PATCH 64/65] remove tmp changes --- charts/tezos/templates/activate-job.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/tezos/templates/activate-job.yaml b/charts/tezos/templates/activate-job.yaml index 579e7ebbb..a2c1060bc 100644 --- a/charts/tezos/templates/activate-job.yaml +++ b/charts/tezos/templates/activate-job.yaml @@ -13,7 +13,7 @@ spec: {{- include "tezos.init_container.chain_initiator" $ | indent 8 }} initContainers: - image: {{ .Values.tezos_k8s_images.utils }} - imagePullPolicy: Always + imagePullPolicy: IfNotPresent name: config-generator args: - config-generator From b414882dd0c28d256643c57090c40eed3fd632e1 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Sat, 9 Dec 2023 15:39:05 -0800 Subject: [PATCH 65/65] fix tests --- test/charts/private-chain.expect.yaml | 98 ++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-) diff --git a/test/charts/private-chain.expect.yaml b/test/charts/private-chain.expect.yaml index 4e6f51768..703a2fd89 100644 --- a/test/charts/private-chain.expect.yaml +++ b/test/charts/private-chain.expect.yaml @@ -829,6 +829,10 @@ spec: extra_args="${extra_args} --operations-pool $(cat /etc/tezos/baker-config/${my_baker_account}_operations_pool)" fi + if [ -f /etc/tezos/baker-config/${my_baker_account}_dal_node ]; then + extra_args="${extra_args} --dal-node $(cat /etc/tezos/baker-config/${my_baker_account}_dal_node)" + fi + CLIENT="$TEZ_BIN/octez-client -d $CLIENT_DIR" CMD="$TEZ_BIN/octez-baker-$proto_command -d $CLIENT_DIR" @@ -906,6 +910,10 @@ spec: extra_args="${extra_args} --operations-pool $(cat /etc/tezos/baker-config/${my_baker_account}_operations_pool)" fi + if [ -f /etc/tezos/baker-config/${my_baker_account}_dal_node ]; then + extra_args="${extra_args} --dal-node $(cat /etc/tezos/baker-config/${my_baker_account}_dal_node)" + fi + CLIENT="$TEZ_BIN/octez-client -d $CLIENT_DIR" CMD="$TEZ_BIN/octez-baker-$proto_command -d $CLIENT_DIR" @@ -983,6 +991,10 @@ spec: extra_args="${extra_args} --operations-pool $(cat /etc/tezos/baker-config/${my_baker_account}_operations_pool)" fi + if [ -f /etc/tezos/baker-config/${my_baker_account}_dal_node ]; then + extra_args="${extra_args} --dal-node $(cat /etc/tezos/baker-config/${my_baker_account}_dal_node)" + fi + CLIENT="$TEZ_BIN/octez-client -d $CLIENT_DIR" CMD="$TEZ_BIN/octez-baker-$proto_command -d $CLIENT_DIR" @@ -1060,6 +1072,10 @@ spec: extra_args="${extra_args} --operations-pool $(cat /etc/tezos/baker-config/${my_baker_account}_operations_pool)" fi + if [ -f /etc/tezos/baker-config/${my_baker_account}_dal_node ]; then + extra_args="${extra_args} --dal-node $(cat /etc/tezos/baker-config/${my_baker_account}_dal_node)" + fi + CLIENT="$TEZ_BIN/octez-client -d $CLIENT_DIR" CMD="$TEZ_BIN/octez-baker-$proto_command -d $CLIENT_DIR" @@ -1137,6 +1153,10 @@ spec: extra_args="${extra_args} --operations-pool $(cat /etc/tezos/baker-config/${my_baker_account}_operations_pool)" fi + if [ -f /etc/tezos/baker-config/${my_baker_account}_dal_node ]; then + extra_args="${extra_args} --dal-node $(cat /etc/tezos/baker-config/${my_baker_account}_dal_node)" + fi + CLIENT="$TEZ_BIN/octez-client -d $CLIENT_DIR" CMD="$TEZ_BIN/octez-baker-$proto_command -d $CLIENT_DIR" @@ -1620,6 +1640,7 @@ spec: args: - "-c" - | + set -e CLIENT="/usr/local/bin/octez-client --endpoint http://tezos-node-rpc:8732" OUTPUT="" @@ -1627,13 +1648,88 @@ spec: sleep 2 done - set -x set -o pipefail if ! echo "$OUTPUT" | grep '"level": 0,'; then echo "Chain already activated, considering activation successful and exiting" exit 0 fi + # Substitute #fromfile with the hex encoded files in question. + # This is for bootstrapped smart rollups. + + # Note that this is low-level string substitution with `read` + # Due to the size of the hex-encoded kernel, using `sed` was not possible. + + PARAMETERS_FILE='/etc/tezos/parameters.json' + TMP_PARAMETERS_FILE='/etc/tezos/tmp_parameters.json' + + # Pattern to search for + pattern='fromfile#' + + # Buffer for characters + buffer='' + + # Whether 'fromfile#' was detected + detected_fromfile=false + + # Process each character + while IFS= read -r -n1 char + do + # Add the character to the buffer + buffer=$(printf "%s%s" "$buffer" "$char") + + # If the buffer ends with the pattern + if [ "${buffer%"$pattern"}" != "$buffer" ] + then + detected_fromfile=true + + # Clear the buffer + buffer='' + + # Read the filename + filename='' + while IFS= read -r -n1 char && [ "$char" != '"' ] + do + filename=$(printf "%s%s" "$filename" "$char") + done + + echo "Found kernel file: $filename" + + # Check if file exists + if [ ! -f "$filename" ]; then + echo "Kernel file $filename not found!" + exit 1 + fi + + # Convert the file content to hex and append to the temp file + xxd -p -c 0 "$filename" | tr -d '\n' >> $TMP_PARAMETERS_FILE + + # Add a closing double quote + printf '"' >> $TMP_PARAMETERS_FILE + elif [ ${#buffer} -ge ${#pattern} ] + then + # Write the oldest character in the buffer to the temporary file + printf "%s" "${buffer%"${buffer#?}"}" >> $TMP_PARAMETERS_FILE + + # Remove the oldest character from the buffer + buffer=${buffer#?} + fi + done < "$PARAMETERS_FILE" + + # If there's anything left in the buffer, write it to the file + if [ -n "$buffer" ] + then + printf "%s" "$buffer" >> $TMP_PARAMETERS_FILE + fi + + # Replace the original parameters.json file with the modified one only if 'fromfile#' was detected + if $detected_fromfile; then + mv $TMP_PARAMETERS_FILE $PARAMETERS_FILE + echo "Updated JSON saved in '$PARAMETERS_FILE'" + else + rm -f $TMP_PARAMETERS_FILE + echo "No 'fromfile#' detected in '$PARAMETERS_FILE', no changes made." + fi echo Activating chain: $CLIENT -d /var/tezos/client --block \ genesis activate protocol \