Skip to content

Commit 1f4c388

Browse files
committed
Apply version overrides
1 parent bc4491d commit 1f4c388

File tree

5 files changed

+55
-3
lines changed

5 files changed

+55
-3
lines changed

.github/workflows/ci.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,14 @@ jobs:
7070
timeout-minutes: 45
7171
steps:
7272
- name: Start container
73-
run: docker run -d --name zetacored -p 8545:8545 -e MONIKER=$(uuidgen) -e ZETACHAIN_NETWORK=testnet ${{ needs.build.outputs.IMAGE }}
73+
run: |
74+
docker run -d \
75+
--name zetacored \
76+
-p 8545:8545 \
77+
-e MONIKER=$(uuidgen) \
78+
-e ZETACHAIN_NETWORK=testnet \
79+
-e VERSION_OVERRIDE_v27=https://github.com/zeta-chain/node/releases/download/v27.0.4/zetacored-linux-amd64 \
80+
${{ needs.build.outputs.IMAGE }}
7481
- name: Wait for healthy
7582
run: |
7683
while ! curl -s -f --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":67}' -H 'Content-Type: application/json' http://localhost:8545; do

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ RUN apt update && \
1414

1515
COPY --from=base-build /go/bin/cosmovisor /go/bin/go-getter /go/bin/dl-pipe /usr/local/bin
1616

17-
COPY run.sh init.sh /
17+
COPY run.sh init.sh apply_version_overrides.sh /
1818

1919
ENTRYPOINT ["/run.sh"]
2020

README.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,14 @@ zetacored-docker is a simple way to run snapshot based `zetacored` in docker. It
22

33
The only environment variable you must set is `MONIKER`. See `run.sh` for the other variables you may set.
44

5-
A persistent volume should be mounted on `/root`.
5+
A persistent volume should be mounted on `/root`.
6+
7+
## Version Overrides
8+
9+
You may override a specific version by setting `VERSION_OVERRIDE_${version}=URL` variable. This is mostly useful for deploying minor non-consensus breaking patches. Example:
10+
11+
```
12+
VERSION_OVERRIDE_v27=https://github.com/zeta-chain/node/releases/download/v27.0.4/zetacored-linux-amd64
13+
```
14+
15+
The old version will be ran if the download of this file changes.

apply_version_overrides.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
set -eo pipefail
4+
5+
if [[ -n $DEBUG ]]; then
6+
set -x
7+
fi
8+
9+
upgrades_path="${HOME}/.zetacored/cosmovisor/upgrades/"
10+
11+
for version_dir in "$upgrades_path"/*/; do
12+
if [ ! -d "$version_dir" ]; then
13+
continue
14+
fi
15+
# Extract version name from path
16+
version=$(basename "$version_dir")
17+
# Check for override variable
18+
override_var="VERSION_OVERRIDE_${version}"
19+
if [ -n "${!override_var}" ]; then
20+
echo "Found override for version $version: ${!override_var}"
21+
# Download binary using go-getter
22+
if go-getter --mode file "${!override_var}" /tmp/zetacored; then
23+
# If download successful, move to correct location
24+
chmod +x /tmp/zetacored
25+
mv /tmp/zetacored "${version_dir}/bin/zetacored"
26+
echo "Successfully updated binary for version $version"
27+
else
28+
echo "Failed to download binary for version $version, using existing version"
29+
fi
30+
fi
31+
done

run.sh

+4
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,9 @@ export DAEMON_NAME="zetacored"
1515
export DAEMON_HOME="$HOME/.zetacored"
1616
export UNSAFE_SKIP_BACKUP=true
1717

18+
# apply any version overrides
19+
# these should run on every start the version can change at any time
20+
/apply_version_overrides.sh
21+
1822
# shellcheck disable=SC2068
1923
exec cosmovisor run start --moniker "$MONIKER" $@

0 commit comments

Comments
 (0)