Skip to content

Commit

Permalink
Install lz4 in Docker image (#7)
Browse files Browse the repository at this point in the history
* Install lz4 in Docker image

Install lz4 in Docker image to support lz4 snapshots.

* Extract new snapshots using lz4

* Add lz4 to snapshotter

* Support decompressing both tar and lz4 snapshots

Co-authored-by: Alex Gartner <[email protected]>

* fix indentation

* fix indentation

---------

Co-authored-by: Julian Rubino <[email protected]>
Co-authored-by: Alex Gartner <[email protected]>
  • Loading branch information
3 people authored Nov 7, 2024
1 parent b8096da commit eae6db1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ FROM debian:bookworm AS base
ENV PATH=/root/.zetacored/cosmovisor/current/bin/:${PATH}

RUN apt update && \
apt install -y ca-certificates curl jq && \
apt install -y ca-certificates curl jq lz4 && \
rm -rf /var/lib/apt/lists/*

COPY --from=base-build /go/bin/cosmovisor /go/bin/go-getter /go/bin/dl-pipe /usr/local/bin
Expand All @@ -23,9 +23,9 @@ FROM base AS snapshotter
ARG TARGETARCH

RUN apt update && \
apt install -y rclone procps && \
apt install -y rclone procps lz4 && \
rm -rf /var/lib/apt/lists/*

RUN ARCH=$( [ "$TARGETARCH" = "amd64" ] && echo "x86_64" || echo "$TARGETARCH" ) && \
curl -L https://github.com/zeta-chain/cosmprund/releases/download/v0.2.0-zeta/cosmprund_Linux_${ARCH}.tar.gz | tar xz -C /usr/local/bin/ cosmprund &&\
chmod +x /usr/local/bin/cosmprund
chmod +x /usr/local/bin/cosmprund
14 changes: 9 additions & 5 deletions init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ elif [[ "$ZETACHAIN_NETWORK" == "testnet" || "$ZETACHAIN_NETWORK" == "athens3" ]
ZETACHAIN_INIT_API_URL=${ZETACHAIN_INIT_API_URL:-"https://zetachain-athens.g.allthatnode.com/archive/rest"}
ZETACHAIN_SNAPSHOT_METADATA_URL=${ZETACHAIN_SNAPSHOT_METADATA_URL:-"https://snapshots.rpc.zetachain.com/testnet/${ZETACHAIN_SNAPSHOT_TYPE}/latest.json"}
ZETACHAIN_NETWORK_CONFIG_URL_BASE=${ZETACHAIN_NETWORK_CONFIG_URL_BASE:-"https://raw.githubusercontent.com/zeta-chain/network-config/main/athens3"}
else
else
echo "Invalid network"
exit 1
fi
Expand Down Expand Up @@ -81,7 +81,7 @@ install_genesis_zetacored() {
.proposals[] |
select(.status == "PROPOSAL_STATUS_PASSED") |
.messages[] |
select(."@type" == "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade" and (.plan.height |
select(."@type" == "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade" and (.plan.height |
tonumber < $max_height))' | jq -s '.[0]' | tee /tmp/init-upgrade-plan.json

ZETACORED_BINARY_URL=$(jq -r '.plan.info' /tmp/init-upgrade-plan.json | jq -r ".binaries[\"linux/$GOARCH\"]")
Expand All @@ -100,7 +100,11 @@ restore_snapshot() {
snapshot_md5=$(echo "$snapshot" | jq -r '.checksums.md5')
echo "Restoring snapshot from ${snapshot_link}"
# https://github.com/zeta-chain/dl-pipe
dl-pipe -hash "md5:${snapshot_md5}" "$snapshot_link" | tar x -C $HOME/.zetacored
decompress_args=""
if [[ "$snapshot_link" == *"lz4"* ]]; then
decompress_args="-I lz4"
fi
dl-pipe -hash "md5:${snapshot_md5}" "$snapshot_link" | tar $decompress_args -x -C $HOME/.zetacored
}

cd $HOME
Expand All @@ -117,9 +121,9 @@ if [[ ! -f /root/init_completed ]]; then
install_genesis_zetacored
restore_snapshot
touch /root/init_completed
else
else
echo "Initialization already completed"
fi

# always set IP address as it may change after restart
sed -i -e "s/^external_address = .*/external_address = \"${MY_IP}:26656\"/" .zetacored/config/config.toml
sed -i -e "s/^external_address = .*/external_address = \"${MY_IP}:26656\"/" .zetacored/config/config.toml

0 comments on commit eae6db1

Please sign in to comment.