Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EVM Sequencer Support #5

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions charts/tezos/scripts/evm-proxy.sh

This file was deleted.

23 changes: 23 additions & 0 deletions charts/tezos/scripts/evm-sequencer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
set -e

TEZ_VAR=/var/tezos
TEZ_BIN=/usr/local/bin
ROLLUP_DATA_DIR="$TEZ_VAR/rollup"
SEQUENCER_DATA_DIR="$TEZ_VAR/sequencer"

set -x

if [ ! -e "/var/tezos/sequencer/store/store.1.mapping" ]; then
octez-evm-node init from rollup node ${ROLLUP_DATA_DIR} \
--data-dir ${SEQUENCER_DATA_DIR}
fi


CMD="$TEZ_BIN/octez-evm-node run sequencer \
with endpoint http://127.0.0.1:8932 \
signing with edsk3rw6fcwjPe5xkGWAbSquLDQALKP8XyMhy4c6PQGr7qQKTYa8rX \
--data-dir ${SEQUENCER_DATA_DIR} \
--time-between-blocks 6 \
--rpc-addr 0.0.0.0"

exec $CMD
16 changes: 12 additions & 4 deletions charts/tezos/scripts/smart-rollup-node.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set -ex
set -e

TEZ_VAR=/var/tezos
TEZ_BIN=/usr/local/bin
Expand All @@ -9,12 +9,20 @@ 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 \

set -x
$TEZ_BIN/octez-smart-rollup-node \
--endpoint http://tezos-node-rpc:8732 \
-d $CLIENT_DIR \
run operator for ${ROLLUP_ADDRESS} with operators ${OPERATORS_PARAMS} \
init operator config for ${ROLLUP_ADDRESS} with operators ${OPERATORS_PARAMS} \
--data-dir ${ROLLUP_DATA_DIR} \
--boot-sector-file /var/tezos/smart-rollup-boot-sector \
--rpc-addr 0.0.0.0"
--rpc-addr 0.0.0.0 \
--force

CMD="$TEZ_BIN/octez-smart-rollup-node \
--endpoint http://tezos-node-rpc:8732 \
-d $CLIENT_DIR \
run \
--data-dir ${ROLLUP_DATA_DIR}"
exec $CMD
28 changes: 28 additions & 0 deletions charts/tezos/scripts/smart-rollup-snapshot-downloader.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

set -e

data_dir="/var/tezos"
rollup_data_dir="$data_dir/rollup"
snapshot_file=$rollup_data_dir/rollup.snapshot

if [ ! -d "$data_dir" ]; then
echo "ERROR: /var/tezos doesn't exist. There should be a volume mounted."
exit 1
fi

if [ -e "$rollup_data_dir/storage/l2_blocks/data" ]; then
echo "Smart rollup snapshot has already been imported. Exiting."
exit 0
fi

# if [ -e "${snapshot_file}" ]; then
# echo "Temporary - snapshot file already dl'd, not doing it again"
# exit 0
# fi

echo "Did not find a pre-existing smart rollup snapshot."

echo "Downloading ${SNAPSHOT_URL}"
mkdir -p "$rollup_data_dir"
curl -LfsS ${SNAPSHOT_URL} | tee >(sha256sum > ${snapshot_file}.sha256sum) > "$snapshot_file"
22 changes: 22 additions & 0 deletions charts/tezos/scripts/smart-rollup-snapshot-importer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
set -ex

bin_dir="/usr/local/bin"
data_dir="/var/tezos"
rollup_data_dir="$data_dir/rollup"
smart_rollup_node="$bin_dir/octez-smart-rollup-node"
snapshot_file=${rollup_data_dir}/rollup.snapshot

if [ ! -f ${snapshot_file} ]; then
echo "No snapshot to import."
exit 0
fi

if [ -e "$rollup_data_dir/storage/l2_blocks/data" ]; then
echo "Smart rollup snapshot has already been imported. Exiting."
exit 0
fi

${smart_rollup_node} --endpoint ${NODE_RPC_URL} snapshot import ${snapshot_file} --data-dir ${rollup_data_dir} --no-check
find ${node_dir}

rm -rvf ${snapshot_file}
145 changes: 54 additions & 91 deletions charts/tezos/templates/octez-rollup-node.yaml
Original file line number Diff line number Diff line change
@@ -1,102 +1,17 @@
{{- range $k, $v := .Values.smartRollupNodes }}

{{- if $v.evm_proxy | default false }}
apiVersion: v1
kind: Service
metadata:
name: evm-proxy-{{ $k }}
name: sequencer-{{ $k }}
namespace: {{ $.Release.Namespace }}
spec:
type: NodePort
ports:
- port: 8545
name: evm-proxy
name: sequencer
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: {{ $.Values.images_pull_policy }}
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 }}
app: rollup-{{ $k }}
---
apiVersion: v1
kind: Service
Expand Down Expand Up @@ -159,7 +74,55 @@ spec:
{{- $cleanKey := regexReplaceAll "[0-9]+$" $key "" }}
{{ $cleanKey }}:{{ $value }}
{{- end }}
- name: octez-sequencer
image: "{{ $.Values.images.octez }}"
imagePullPolicy: {{ $.Values.images_pull_policy }}
ports:
- containerPort: 8545
name: sequencer
command:
- /bin/sh
args:
- "-c"
- |
{{ tpl ($.Files.Get "scripts/evm-sequencer.sh") $ | indent 12 }}
volumeMounts:
- mountPath: /var/tezos
name: var-volume
env:
- name: MY_POD_NAME
value: {{ $k }}
initContainers:
- name: snapshot-downloader
image: "{{ $.Values.tezos_k8s_images.utils }}"
imagePullPolicy: {{ $.Values.tezos_k8s_images_pull_policy }}
command:
- /bin/sh
volumeMounts:
- mountPath: /var/tezos
name: var-volume
args:
- "-c"
- |
{{ tpl ($.Files.Get "scripts/smart-rollup-snapshot-downloader.sh") $ | indent 12 }}
env:
- name: SNAPSHOT_URL
value: {{ $v.snapshot_url }}
- name: snapshot-importer
image: "{{ $.Values.images.octez }}"
imagePullPolicy: {{ $.Values.images_pull_policy }}
command:
- /bin/sh
volumeMounts:
- mountPath: /var/tezos
name: var-volume
args:
- "-c"
- |
{{ tpl ($.Files.Get "scripts/smart-rollup-snapshot-importer.sh") $ | indent 12 }}
env:
- name: NODE_RPC_URL
value: {{ $v.node_rpc_url }}
- image: {{ $.Values.tezos_k8s_images.utils }}
imagePullPolicy: {{ $.Values.tezos_k8s_images_pull_policy }}
name: config-generator
Expand All @@ -180,9 +143,9 @@ spec:
name: tezos-accounts
securityContext:
fsGroup: 1000
{{/* runAsUser: 1000 */}}
{{/* runAsGroup: 1000 */}}
volumes:
- volume: var-volume
name: var-volume
- name: tezos-accounts
secret:
secretName: tezos-secret
Expand All @@ -194,7 +157,7 @@ spec:
- ReadWriteOnce
resources:
requests:
storage: "15Gi"
storage: "50Gi"
---
{{- if $v.ingress | default false }}
{{- if $v.ingress.enabled | default false }}
Expand Down
Loading
Loading