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

Add initial basic simulator support #233

Merged
merged 3 commits into from
Feb 21, 2024
Merged
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
@@ -1 +1,2 @@
.idea/*
sim-root
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ ENV farmer="false"
# netcat: Healthchecking the daemon
# yq: changing config settings
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y sudo tzdata curl netcat-traditional && \
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y sudo tzdata curl netcat-traditional jq && \
rm -rf /var/lib/apt/lists/* && \
ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" > /etc/timezone && \
dpkg-reconfigure -f noninteractive tzdata
Expand Down
22 changes: 22 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,28 @@ cd /chia-blockchain || exit 1
# shellcheck disable=SC1091
. ./activate

# Set a few overrides if the service variable contains simulator
if [ -z "${service##*simulator*}" ]; then
echo "Setting up environment for simulator..."
export CHIA_ROOT=/root/.chia/simulator/main
export self_hostname="0.0.0.0"

if [ -f /root/.chia/simulator/mnemonic ]; then
echo "Using provided mnemonic from /root/.chia/simulator/mnemonic"
# Use awk to trim leading and trailing whitespace while preserving internal spaces
mnemonic=$(awk '{$1=$1};1' /root/.chia/simulator/mnemonic)
fi

if [ -n "$mnemonic" ]; then # Check if mnemonic is non-empty after trimming
chia dev sim create --docker-mode --mnemonic "${mnemonic}"
else
chia dev sim create --docker-mode
fi

chia stop -d all
chia keys show --show-mnemonic-seed --json | jq -r '.keys[0].mnemonic' > /root/.chia/simulator/mnemonic
fi

# shellcheck disable=SC2086
chia ${chia_args} init --fix-ssl-permissions

Expand Down
6 changes: 6 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,3 +326,9 @@ readinessProbe:
```

See [Configure Probes](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes) for more information about configuring readiness and liveness probes for Kubernetes clusters. The `initialDelaySeconds` parameter may need to be adjusted higher or lower depending on the speed to start up on the host the container is running on.

## Simulator

`docker run -e service=simulator -v /local/path/to/simulator:/root/.chia/simulator ghcr.io/chia-network/chia:latest`

Mounts the simulator root to the provided local path to make the test plots and the mnemonic persistent. Mnemonic will be available at /local/path/to/simulator/mnemonic
Loading