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

Maintaining simple-optimism-node to work with latest OP Node #97

Merged
merged 9 commits into from
Oct 23, 2023
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
2 changes: 1 addition & 1 deletion docker/dockerfiles/Dockerfile.bedrock-init
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM ubuntu:22.04
ARG DEBIAN_FRONTEND=noninteractive

# Install required packages.
RUN apt-get update && apt install -y curl wget git rsync build-essential openssl python3 python3-pip
RUN apt-get update && apt install -y curl wget git rsync build-essential openssl python3 python3-pip aria2 zstd

# Install Go.
RUN curl -sSL https://golang.org/dl/go1.19.5.linux-amd64.tar.gz | tar -v -C /usr/local -xz
Expand Down
22 changes: 20 additions & 2 deletions scripts/init-bedrock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,32 @@ fi
echo "Bedrock node needs to be initialized..."
echo "Initializing via download..."

# Fix OP link with hardcoded official OP snapshot
echo "Fetching download link..."
BEDROCK_TAR_DOWNLOAD=$(config "bedrock/$NETWORK_NAME/bedrock-download")
if [ "$NETWORK_NAME" = "mainnet" ]; then
BEDROCK_TAR_DOWNLOAD="https://datadirs.optimism.io/mainnet-bedrock.tar.zst"
elif [ "$NETWORK_NAME" = "goerli" ]; then
BEDROCK_TAR_DOWNLOAD="https://datadirs.optimism.io/goerli-bedrock.tar.zst"
else
BEDROCK_TAR_DOWNLOAD=$(config "bedrock/$NETWORK_NAME/bedrock-download")
fi

if [[ "$BEDROCK_TAR_DOWNLOAD" == *.zst ]]; then
BEDROCK_TAR_PATH+=".zst"
fi

echo "Downloading bedrock.tar..."
download $BEDROCK_TAR_DOWNLOAD $BEDROCK_TAR_PATH

echo "Extracting bedrock.tar..."
extract $BEDROCK_TAR_PATH $GETH_DATA_DIR
if [[ "$BEDROCK_TAR_DOWNLOAD" == *.zst ]]; then
extractzst $BEDROCK_TAR_PATH $GETH_DATA_DIR
else
extract $BEDROCK_TAR_PATH $GETH_DATA_DIR
fi

# Remove tar file to save disk space
rm $BEDROCK_TAR_PATH

echo "Creating JWT..."
mkdir -p $(dirname $BEDROCK_JWT_PATH)
Expand Down
11 changes: 10 additions & 1 deletion scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ function extract() {
tar -xf $1 -C $2
}

# extract: Extracts a zst archive into an output location.
# Arguments:
# arc: ZST archive to to extract.
# loc: Location to extract to.
function extractzst() {
mkdir -p $2
tar --use-compress-program=unzstd -xf $1 -C $2
}

# download: Downloads a file and provides basic progress percentages.
# Arguments:
# url: URL of the file to download.
Expand All @@ -17,7 +26,7 @@ function download() {
SIZE=$(curl -sI $1 | grep -i Content-Length | awk '{print $2}')
(while true ; do sleep 60; echo "$(ls -l $2 | awk -v size=$SIZE '{printf "Download Progress: %.2f%%\n", $5/size*100}')"; done) &
monitor_pid=$!
wget -c -o $2 $1
aria2c --max-tries=0 -o $2 $1
kill $monitor_pid
}

Expand Down
Loading