diff --git a/charts/tezos/scripts/baker.sh b/charts/tezos/scripts/baker.sh index 8063446c6..d4c68258b 100644 --- a/charts/tezos/scripts/baker.sh +++ b/charts/tezos/scripts/baker.sh @@ -42,6 +42,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/scripts/chain-initiator.sh b/charts/tezos/scripts/chain-initiator.sh index bb246c04b..0ef545f65 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" OUTPUT="" @@ -5,13 +6,88 @@ until OUTPUT=$($CLIENT rpc get /chains/main/blocks/head/header) && echo "$OUTPUT 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 \ diff --git a/charts/tezos/scripts/dal-node.sh b/charts/tezos/scripts/dal-node.sh new file mode 100644 index 000000000..31155068f --- /dev/null +++ b/charts/tezos/scripts/dal-node.sh @@ -0,0 +1,35 @@ +set -ex + +TEZ_VAR=/var/tezos +TEZ_BIN=/usr/local/bin +DAL_DATA_DIR="$TEZ_VAR/dal" + +mkdir -p ${DAL_DATA_DIR} + +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 [ "${PEER}" != "" ]; then + extra_args="${extra_args} --peer ${PEER}" +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 \ + --net-addr 0.0.0.0:11732 \ + --rpc-addr 0.0.0.0:10732" + +exec $CMD diff --git a/charts/tezos/scripts/evm-proxy.sh b/charts/tezos/scripts/evm-proxy.sh new file mode 100644 index 000000000..a62c08896 --- /dev/null +++ b/charts/tezos/scripts/evm-proxy.sh @@ -0,0 +1,10 @@ +set -ex + +TEZ_BIN=/usr/local/bin + +CMD="$TEZ_BIN/octez-evm-node run proxy \ + with endpoint http://rollup-${MY_POD_NAME}:8932 \ + --devmode \ + --rpc-addr 0.0.0.0" + +exec $CMD diff --git a/charts/tezos/scripts/smart-rollup-node.sh b/charts/tezos/scripts/smart-rollup-node.sh new file mode 100644 index 000000000..0df3d4861 --- /dev/null +++ b/charts/tezos/scripts/smart-rollup-node.sh @@ -0,0 +1,20 @@ +set -ex + +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 -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 \ + --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" + +exec $CMD diff --git a/charts/tezos/templates/configs.yaml b/charts/tezos/templates/configs.yaml index 7b6bf9c09..7bb4b02ba 100644 --- a/charts/tezos/templates/configs.yaml +++ b/charts/tezos/templates/configs.yaml @@ -59,6 +59,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 }} --- @@ -94,6 +96,9 @@ data: {{- if $account.operations_pool }} {{ $accountName }}_operations_pool: {{ $account.operations_pool | quote }} {{- end }} + {{- if $account.dal_node }} + {{ $accountName }}_dal_node: {{ $account.dal_node | quote }} + {{- end }} {{- end }} kind: ConfigMap metadata: diff --git a/charts/tezos/templates/octez-dal-node.yaml b/charts/tezos/templates/octez-dal-node.yaml new file mode 100644 index 000000000..8ea4803b5 --- /dev/null +++ b/charts/tezos/templates/octez-dal-node.yaml @@ -0,0 +1,135 @@ +{{- range $k, $v := .Values.dalNodes }} + +apiVersion: v1 +kind: Service +metadata: + name: dal-{{ $k }} + namespace: {{ $.Release.Namespace }} +spec: + type: NodePort + ports: + - port: 10732 + name: rpc + - port: 11732 + name: p2p + 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: 10732 + name: rpc + - containerPort: 11732 + name: p2p + command: + - /bin/sh + volumeMounts: + - mountPath: /var/tezos + name: var-volume + args: + - "-c" + - | +{{ tpl ($.Files.Get "scripts/dal-node.sh") $ | indent 12 }} +{{- if $v | default false }} + env: +{{- if $v.bootstrapProfile | default false }} + - name: BOOTSTRAP_PROFILE + value: "true" +{{- end }} +{{- if $v.attesterProfiles | default false }} + - 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 }}" +{{- end }} +{{- if $v.identity | default false }} + - name: IDENTITY_JSON + value: {{ toJson $v.identity | quote }} +{{- end }} +{{- end }} + securityContext: + fsGroup: 1000 + volumeClaimTemplates: + - metadata: + name: var-volume + spec: + accessModes: + - ReadWriteOnce + resources: + requests: +{{- if $v.storageSize | default false }} + storage: "{{ $v.storageSize }}" +{{- else }} + storage: "50Gi" +{{- end }} +--- +{{- if $v | default false }} +{{- 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: rpc +--- +{{- end }} +{{- end }} +{{- end }} +{{- end }} diff --git a/charts/tezos/templates/octez-rollup-node.yaml b/charts/tezos/templates/octez-rollup-node.yaml new file mode 100644 index 000000000..870e6bb3f --- /dev/null +++ b/charts/tezos/templates/octez-rollup-node.yaml @@ -0,0 +1,235 @@ +{{- range $k, $v := .Values.smartRollupNodes }} + +{{- if $v.evm_proxy | default false }} +apiVersion: v1 +kind: Service +metadata: + name: evm-proxy-{{ $k }} + namespace: {{ $.Release.Namespace }} +spec: + type: NodePort + ports: + - port: 8545 + name: evm-proxy + selector: + app: evm-proxy-{{ $k }} +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: evm-proxy-{{ $k }} + namespace: {{ $.Release.Namespace }} +{{- if $v.evm_proxy.annotations | default false }} +{{- with $v.evm_proxy.annotations }} + annotations: + {{- toYaml . | nindent 4 }} +{{- end }} +{{- end }} +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 }} + env: + - name: MY_POD_NAME + value: {{ $k }} + 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: Prefix + path: / + backend: + service: + name: evm-proxy-{{ $k }} + port: + name: evm-proxy +{{- end }} +{{- end }} +{{- end }} +--- +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: 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 + serviceName: rollup-{{ $k }} + selector: + matchLabels: + app: rollup-{{ $k }} + template: + metadata: + labels: + app: rollup-{{ $k }} + spec: + containers: + - name: octez-smart-rollup-node + image: "{{ $.Values.images.octez }}" + imagePullPolicy: IfNotPresent + ports: + - containerPort: 8932 + name: rollup + 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 + value: {{ $k }} + - 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: + - 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: 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: Prefix + path: / + backend: + service: + name: rollup-{{ $k }} + port: + name: rollup +{{- end }} +{{- end }} +{{- end }} diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index d8586da44..7376512c6 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -18,6 +18,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. @@ -45,6 +48,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 @@ -66,6 +71,7 @@ accounts: {} # baker1: # key: edsk... # operations_pool: http://flashbake-endpoint-baker-listener:12732 +# dal_node: http://dal_node:10732 # protocols: # - command: PtMumbai # vote: @@ -174,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`. # @@ -338,6 +343,70 @@ 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. +# If your rollup is an EVM rollup, you can also define an EVM proxy object, +# which can in turn have an ingress. +# +smartRollupNodes: {} +# Example: +# ``` +# smartRollupNodes: +# rollup-node-0: +# operator_account: archive-baking-node-0 +# rollup_address: sr1RYurGZtN8KNSpkMcCt9CgWeUaNkzsAfXf +# annotations: {} +# ingress: +# enabled: false +# host: "" +# annotations: {} +# className: "" +# labels: {} +# pathType: Prefix +# tls: [] +# evm_proxy: +# annotations: {} +# ingress: +# enabled: false +# host: "" +# annotations: {} +# className: "" +# labels: {} +# pathType: Prefix +# tls: [] +# ``` + +# End Rollup Nodes + +# DAL Nodes +dalNodes: {} +# Deploys DAL nodes in pods and maps them to L1 nodes. +# Example: +# bootstrap: +# bootstrapProfile: true +# ingress: +# 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: +# storageSize: 50Gi +# 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 @@ -517,6 +586,16 @@ 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" +# 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. ## Supported indexers: diff --git a/test/charts/mainnet.expect.yaml b/test/charts/mainnet.expect.yaml index dc9634d3b..0d94865b1 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 7c3218c14..1efec4ed2 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 ce7f7de45..703a2fd89 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 @@ -827,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" @@ -904,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" @@ -981,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" @@ -1058,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" @@ -1135,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" @@ -1618,6 +1640,7 @@ spec: args: - "-c" - | + set -e CLIENT="/usr/local/bin/octez-client --endpoint http://tezos-node-rpc:8732" OUTPUT="" @@ -1625,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 \ diff --git a/utils/config-generator.py b/utils/config-generator.py index e3bb1d99f..9b3a74ec7 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"] @@ -340,6 +343,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 @@ -560,6 +566,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