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

feat: Add deployment option for etherlink #16

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ node_modules
.devspace/
build

.idea

# Ignore mkchain generated files
*_values.yaml
Expand Down
49 changes: 49 additions & 0 deletions charts/tezos/scripts/evm-observer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
set -ex

TEZ_VAR=/var/tezos
TEZ_BIN=/usr/local/bin
ROLLUP_DATA_DIR="${TEZ_VAR}/rollup"
EVM_DATA_DIR="${TEZ_VAR}/evm"
EVM_CONFIG_FILE="${EVM_DATA_DIR}/config.json"

EVM_CONFIGMAP_DIR="${TEZ_VAR}/evm-config"
EVM_CONFIGMAP_CONFIG_FILE="${EVM_CONFIGMAP_DIR}/config.json"

# Wait till rollup node to be fully synchronized to run init from rollup command
WAIT_LIMIT=30
COUNTER=1
while [ "$(curl -s http://localhost:8932/local/synchronized | sed 's/^"//;s/"$//')" != "synchronized" ] && [ $COUNTER -lt $WAIT_LIMIT ]; do
COUNTER=$((COUNTER + 1))
echo "polling ${COUNTER}/${WAIT_LIMIT}: rollup node not synchronized yet"
sleep 60
done

if [ "$(curl -s http://localhost:8932/local/synchronized | sed 's/^"//;s/"$//')" != "synchronized" ]; then
echo "ERROR: rollup node not synchronized within wait limit, exiting...."
exit 1
fi

if [ ! -e "${EVM_DATA_DIR}/store.sqlite" ]; then
$TEZ_BIN/octez-evm-node init from rollup node ${ROLLUP_DATA_DIR} --data-dir ${EVM_DATA_DIR}
fi

# Provide basic config if there is no config specified in values.yaml
if [ ! -e "${EVM_CONFIGMAP_CONFIG_FILE}" ]; then
cat > "${EVM_CONFIG_FILE}" << EOF
{ "rpc-addr": "0.0.0.0", "cors_origins": [ "*" ],
"cors_headers": [ "*" ],
"rollup_node_endpoint": "http://127.0.0.1:8932", "verbose": "notice",
"max_active_connections": 8000 }
EOF
else
cp -vf ${EVM_CONFIGMAP_CONFIG_FILE} ${EVM_CONFIG_FILE}
fi

CMD="$TEZ_BIN/octez-evm-node run observer \
--evm-node-endpoint ${EVM_NODE_ENDPOINT} \
--rollup-node-endpoint http://127.0.0.1:8932 \
--data-dir ${EVM_DATA_DIR} \
--preimages-endpoint ${ROLLUP_PREIMAGES_ENDPOINT} \
--rpc-addr 0.0.0.0 --rpc-port 8545"

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

TEZ_VAR=/var/tezos
TEZ_BIN=/usr/local/bin
ROLLUP_DATA_DIR="$TEZ_VAR/rollup"
EVM_DATA_DIR="$TEZ_VAR/evm"

set -x

if [ ! -e "${EVM_DATA_DIR}/store/store.dict" ]; then
$TEZ_BIN/octez-evm-node init from rollup node ${ROLLUP_DATA_DIR} --data-dir ${EVM_DATA_DIR}
fi


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

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

TEZ_VAR=/var/tezos
EVM_DATA_DIR="${TEZ_VAR}/evm"
SNAPSHOT_FILE="${EVM_DATA_DIR}/snapshot.gz"

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

if [ -e "${EVM_DATA_DIR}/store.sqlite" ]; then
echo "EVM node data is already populated"
exit 0
fi

echo "Couldn't find a pre-existing evm snapshot."

echo "Downloading ${EVM_SNAPSHOT_URL}"
mkdir -p "${EVM_DATA_DIR}"
curl -LfsS ${EVM_SNAPSHOT_URL} | tee >(sha256sum > ${SNAPSHOT_FILE}.sha256sum) > "${SNAPSHOT_FILE}"

chown -R 1000:1000 "${EVM_DATA_DIR}"
23 changes: 23 additions & 0 deletions charts/tezos/scripts/evm-snapshot-importer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
set -ex

TEZ_VAR=/var/tezos
TEZ_BIN=/usr/local/bin
EVM_DATA_DIR="${TEZ_VAR}/evm"
SNAPSHOT_FILE="${EVM_DATA_DIR}/snapshot.gz"

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

if [ -e "${EVM_DATA_DIR}/store.sqlite" ]; then
echo "EVM node data is already populated"
exit 0
fi

"${TEZ_BIN}/octez-evm-node" snapshot import ${SNAPSHOT_FILE} --data-dir ${EVM_DATA_DIR}

echo "List populated data dir of evm "
find ${EVM_DATA_DIR}

rm -rvf ${SNAPSHOT_FILE}
23 changes: 23 additions & 0 deletions charts/tezos/scripts/smart-rollup-observer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
set -ex

TEZ_VAR=/var/tezos
TEZ_BIN=/usr/local/bin
ROLLUP_DATA_DIR="${TEZ_VAR}/rollup"

$TEZ_BIN/octez-smart-rollup-node init observer \
config for "${ROLLUP_ADDRESS}" \
with operators \
--history-mode "${ROLLUP_HISTORY_MODE}" \
--data-dir "${ROLLUP_DATA_DIR}" \
--rpc-addr 0.0.0.0 \
--pre-images-endpoint "${ROLLUP_PREIMAGES_ENDPOINT}" \
--force

CMD="$TEZ_BIN/octez-smart-rollup-node \
--endpoint ${NODE_RPC_URL} \
run \
--data-dir ${ROLLUP_DATA_DIR} \
--acl-override allow-all \
--log-kernel-debug"

exec $CMD
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 ${NODE_RPC_URL} \
-d $CLIENT_DIR \
run \
--data-dir ${ROLLUP_DATA_DIR}"
exec $CMD
30 changes: 30 additions & 0 deletions charts/tezos/scripts/smart-rollup-snapshot-downloader.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/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/store.sqlite" ]; 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"

chown -R 1000:1000 "$data_dir"
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/store.sqlite" ]; 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}
Loading
Loading