Skip to content

Commit

Permalink
feat: Add integration for etherlink
Browse files Browse the repository at this point in the history
  • Loading branch information
puppetninja committed Sep 13, 2024
1 parent 618c2f1 commit 857e111
Show file tree
Hide file tree
Showing 12 changed files with 376 additions and 91 deletions.
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/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 archive \
--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 http://tezos-node-rpc:8732 \
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 http://tezos-node-rpc:8732 \
-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/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"

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/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}
Loading

0 comments on commit 857e111

Please sign in to comment.