Skip to content

Commit

Permalink
Merge pull request #472 from oasisprotocol/matevz/fix/docker-emerald-dev
Browse files Browse the repository at this point in the history
fix: emerald-dev initialization
  • Loading branch information
matevz authored Oct 30, 2023
2 parents b31d35e + ab39c28 commit 88f0d26
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
load: true

- name: Test
timeout-minutes: 5
timeout-minutes: 2
working-directory: docker/${{ matrix.docker_image }}
run: ./test.sh

Expand Down
24 changes: 11 additions & 13 deletions docker/common/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# - OASIS_WEB3_GATEWAY: path to oasis-web3-gateway binary
# - OASIS_WEB3_GATEWAY_CONFIG_FILE: path to oasis-web3-gateway config file
# - OASIS_DEPOSIT: path to oasis-deposit binary
# - SAPPHIRE_BACKEND: uses 'mock' backend by default
# - BEACON_BACKEND: beacon epoch transition mode 'mock' (default) or 'default'
# - OASIS_SINGLE_COMPUTE_NODE: (default: true) if non-empty only run a single compute node

export OASIS_SINGLE_COMPUTE_NODE=${OASIS_SINGLE_COMPUTE_NODE-1}
Expand All @@ -18,11 +18,7 @@ VERSION=$(cat /VERSION)
echo "${PARATIME_NAME}-dev ${VERSION} (oasis-core: ${OASIS_CORE_VERSION}, ${PARATIME_NAME}-paratime: ${PARATIME_VERSION}, oasis-web3-gateway: ${OASIS_WEB3_GATEWAY_VERSION})"
echo

if [[ ${PARATIME_NAME} == 'sapphire' ]]; then
export SAPPHIRE_BACKEND=${SAPPHIRE_BACKEND:-mock}
else
export SAPPHIRE_BACKEND=default
fi
export BEACON_BACKEND=${BEACON_BACKEND:-mock}

OASIS_NODE_SOCKET=${OASIS_NODE_DATADIR}/net-runner/network/client-0/internal.sock
OASIS_KM_SOCKET=${OASIS_NODE_DATADIR}/net-runner/network/keymanager-0/internal.sock
Expand Down Expand Up @@ -55,7 +51,7 @@ OASIS_WEB3_GATEWAY_PID=$!

# Wait for compute nodes before initiating deposit.
echo -n " * Bootstrapping network (this might take a minute)"
if [[ ${SAPPHIRE_BACKEND} == 'mock' ]]; then
if [[ ${BEACON_BACKEND} == 'mock' ]]; then
echo -n .
${OASIS_NODE} debug control wait-nodes -n 2 -a unix:${OASIS_NODE_SOCKET}

Expand All @@ -66,11 +62,13 @@ if [[ ${SAPPHIRE_BACKEND} == 'mock' ]]; then
${OASIS_NODE} debug control set-epoch --epoch 2 -a unix:${OASIS_NODE_SOCKET}

# Transition to the final epoch when the KM generates ephemeral secret.
while (${OASIS_NODE} control status -a unix:${OASIS_KM_SOCKET} | jq -e ".keymanager.worker.ephemeral_secrets.last_generated_epoch!=3" >/dev/null); do
sleep 0.5
done
echo -n .
${OASIS_NODE} debug control set-epoch --epoch 3 -a unix:${OASIS_NODE_SOCKET}
if [[ ${PARATIME_NAME} == 'sapphire' ]]; then
while (${OASIS_NODE} control status -a unix:${OASIS_KM_SOCKET} | jq -e ".keymanager.worker.ephemeral_secrets.last_generated_epoch!=3" >/dev/null); do
sleep 0.5
done
echo -n .
${OASIS_NODE} debug control set-epoch --epoch 3 -a unix:${OASIS_NODE_SOCKET}
fi
else
${OASIS_NODE} debug control wait-ready -a unix:${OASIS_NODE_SOCKET}
fi
Expand All @@ -85,7 +83,7 @@ echo "WARNING: The chain is running in ephemeral mode. State will be lost after
echo
echo "Listening on http://localhost:8545 and ws://localhost:8546"

if [[ ${SAPPHIRE_BACKEND} == 'mock' ]]; then
if [[ ${BEACON_BACKEND} == 'mock' ]]; then
# Run background task to switch epochs every 5 minutes
while true; do
sleep $((60*10))
Expand Down
10 changes: 5 additions & 5 deletions docker/emerald-dev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ COPY tests/tools/* /

# Configure oasis-node and oasis-net-runner.
RUN wget --quiet "https://github.com/oasisprotocol/oasis-core/releases/download/v${OASIS_CORE_VERSION}/oasis_core_${OASIS_CORE_VERSION}_linux_amd64.tar.gz" \
&& tar xfvz "oasis_core_${OASIS_CORE_VERSION}_linux_amd64.tar.gz" \
&& tar xfvz "oasis_core_${OASIS_CORE_VERSION}_linux_amd64.tar.gz" \
&& mkdir -p "$(dirname ${OASIS_NODE})" "$(dirname ${OASIS_NET_RUNNER})" \
&& mv "oasis_core_${OASIS_CORE_VERSION}_linux_amd64/oasis-node" "${OASIS_NODE}" \
&& mv "oasis_core_${OASIS_CORE_VERSION}_linux_amd64/oasis-net-runner" "${OASIS_NET_RUNNER}" \
Expand All @@ -59,14 +59,14 @@ RUN wget --quiet "https://github.com/oasisprotocol/oasis-core/releases/download/
&& echo "" \
&& echo "Configure the ParaTime." \
&& mkdir -p "$(dirname ${PARATIME})" \
&& wget --quiet "https://github.com/oasisprotocol/${PARATIME_NAME}-paratime/releases/download/v${PARATIME_VERSION}/localnet-${PARATIME_NAME}-paratime.orc" -O "/paratime.orc" \
&& unzip "paratime.orc" \
&& chmod a+x "runtime.elf" \
&& wget --quiet "https://github.com/oasisprotocol/${PARATIME_NAME}-paratime/releases/download/v${PARATIME_VERSION}/localnet-${PARATIME_NAME}-paratime.orc" -O "/paratime.orc" \
&& unzip "paratime.orc" \
&& chmod a+x "runtime.elf" \
&& rm "paratime.orc" \
&& echo "" \
&& echo "Configure oasis-cli." \
&& wget --quiet "https://github.com/oasisprotocol/cli/releases/download/v${OASIS_CLI_VERSION}/oasis_cli_${OASIS_CLI_VERSION}_linux_amd64.tar.gz" \
&& tar -xvf "/oasis_cli_${OASIS_CLI_VERSION}_linux_amd64.tar.gz" \
&& tar -xvf "/oasis_cli_${OASIS_CLI_VERSION}_linux_amd64.tar.gz" \
&& mv "/oasis_cli_${OASIS_CLI_VERSION}_linux_amd64/oasis" / \
&& rm -rf "/oasis_cli_${OASIS_CLI_VERSION}_linux_amd64/" \
&& rm -rf "/oasis_cli_${OASIS_CLI_VERSION}_linux_amd64.tar.gz" \
Expand Down
3 changes: 0 additions & 3 deletions docker/emerald-dev/test.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/bin/bash

# Temporarily disabled. See https://github.com/oasisprotocol/oasis-web3-gateway/issues/471
exit 0

set -euo pipefail

TAG=${TAG:-ghcr.io/oasisprotocol/emerald-dev:local}
Expand Down
8 changes: 4 additions & 4 deletions tests/tools/spinup-oasis-stack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -euo pipefail
# Supported ENV Variables:
# - OASIS_NODE: path to oasis-node binary
# - OASIS_NET_RUNNER: path to oasis-net-runner binary
# - SAPPHIRE_BACKEND: choose 'mock' backend (default), or use other behavior
# - BEACON_BACKEND: choose 'mock' backend (default), or use other behavior
# - PARATIME: path to ParaTime binary (inside .orc bundle)
# - PARATIME_VERSION: version of the binary. e.g. 3.0.0
# - OASIS_NODE_DATADIR: path to temporary oasis-node data dir e.g. /tmp/oasis-localnet
Expand Down Expand Up @@ -45,8 +45,8 @@ fi
if [[ ! -z "${OASIS_SINGLE_COMPUTE_NODE:-}" ]]; then
jq "
.compute_workers = [.compute_workers[0]] |
.runtimes[1].executor.group_size = 1 |
.runtimes[1].executor.group_backup_size = 0
.runtimes[${RT_IDX}].executor.group_size = 1 |
.runtimes[${RT_IDX}].executor.group_backup_size = 0
" "$FIXTURE_FILE" >"$FIXTURE_FILE.tmp"
mv "$FIXTURE_FILE.tmp" "$FIXTURE_FILE"
fi
Expand All @@ -58,7 +58,7 @@ jq "
" "$FIXTURE_FILE" >"$FIXTURE_FILE.tmp"
mv "$FIXTURE_FILE.tmp" "$FIXTURE_FILE"

if [[ ${SAPPHIRE_BACKEND-} == 'mock' ]]; then
if [[ ${BEACON_BACKEND-} == 'mock' ]]; then
# Set beacon backend to 'debug mock'
jq ".network.beacon.debug_mock_backend = true" "$FIXTURE_FILE" >"$FIXTURE_FILE.tmp"
mv "$FIXTURE_FILE.tmp" "$FIXTURE_FILE"
Expand Down

0 comments on commit 88f0d26

Please sign in to comment.