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

Support Erigon v3 #1896

Merged
merged 1 commit into from
Aug 10, 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
10 changes: 1 addition & 9 deletions erigon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ services:
- ARCHIVE_NODE=${ARCHIVE_NODE:-}
- NETWORK=${NETWORK}
- IPV6=${IPV6:-false}
- DOCKER_TAG=${ERIGON_DOCKER_TAG:-stable}
volumes:
- erigon-el-data:/var/lib/erigon
- /etc/localtime:/etc/localtime:ro
Expand Down Expand Up @@ -87,15 +88,6 @@ services:
- /var/lib/erigon/ee-secret/jwtsecret
- --maxpeers
- ${EL_MAX_PEER_COUNT:-100}
# To assist with recordsize 16k in ZFS
- --db.pagesize
- 16K
# Breaking change from 2.55 on
- --db.size.limit
- 8TB
# Memory use reduction. Not needed with 32G and does not help with 16G
#- --batchSize
#- 64m
labels:
- metrics.scrape=true
- metrics.path=/debug/metrics/prometheus
Expand Down
64 changes: 38 additions & 26 deletions erigon/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,34 +54,46 @@ else
__network="--chain ${NETWORK} --http.api web3,eth,net,engine"
fi

# Check for network, and set prune accordingly

if [ "${ARCHIVE_NODE}" = "true" ]; then
echo "Erigon archive node without pruning"
__prune=""
#if [[ "${DOCKER_TAG}" =~ "v3" || "${DOCKER_TAG}" = "latest" || "${DOCKER_TAG}" = "stable" ]]; then # No stable yet
if [[ "${DOCKER_TAG}" =~ "v3" || "${DOCKER_TAG}" = "latest" ]]; then
if [ "${ARCHIVE_NODE}" = "true" ]; then
echo "Erigon archive node without pruning"
__prune="--prune.mode=archive"
else
echo "Erigon full node with pruning"
__prune="--prune.mode=full"
fi
__db_params="--externalcl=true"
else
if [[ "${NETWORK}" = "mainnet" ]]; then
echo "mainnet: Running with prune.r.before=11052984 for eth deposit contract"
__prune="--prune=htc --prune.r.before=11052984"
elif [[ "${NETWORK}" = "goerli" ]]; then
echo "goerli: Running with prune.r.before=4367322 for eth deposit contract"
__prune="--prune=htc --prune.r.before=4367322"
elif [[ "${NETWORK}" = "sepolia" ]]; then
echo "sepolia: Running with prune.r.before=1273020 for eth deposit contract"
__prune="--prune=htc --prune.r.before=1273020"
elif [[ "${NETWORK}" = "gnosis" ]]; then
echo "gnosis: Running with prune.r.before=19469077 for gno deposit contract"
__prune="--prune=htc --prune.r.before=19469077"
elif [[ "${NETWORK}" = "holesky" ]]; then
echo "holesky: Running without prune.r for eth deposit contract"
__prune="--prune=htc"
elif [[ "${NETWORK}" =~ ^https?:// ]]; then
echo "Custom testnet: Running without prune.r for eth deposit contract"
__prune="--prune=htc"
# Check for network, and set prune accordingly
if [ "${ARCHIVE_NODE}" = "true" ]; then
echo "Erigon archive node without pruning"
__prune=""
else
echo "Unable to determine eth deposit contract, running without prune.r"
__prune="--prune=htc"
if [[ "${NETWORK}" = "mainnet" ]]; then
echo "mainnet: Running with prune.r.before=11052984 for eth deposit contract"
__prune="--prune=htc --prune.r.before=11052984"
elif [[ "${NETWORK}" = "goerli" ]]; then
echo "goerli: Running with prune.r.before=4367322 for eth deposit contract"
__prune="--prune=htc --prune.r.before=4367322"
elif [[ "${NETWORK}" = "sepolia" ]]; then
echo "sepolia: Running with prune.r.before=1273020 for eth deposit contract"
__prune="--prune=htc --prune.r.before=1273020"
elif [[ "${NETWORK}" = "gnosis" ]]; then
echo "gnosis: Running with prune.r.before=19469077 for gno deposit contract"
__prune="--prune=htc --prune.r.before=19469077"
elif [[ "${NETWORK}" = "holesky" ]]; then
echo "holesky: Running without prune.r for eth deposit contract"
__prune="--prune=htc"
elif [[ "${NETWORK}" =~ ^https?:// ]]; then
echo "Custom testnet: Running without prune.r for eth deposit contract"
__prune="--prune=htc"
else
echo "Unable to determine eth deposit contract, running without prune.r"
__prune="--prune=htc"
fi
fi
__db_params="--db.pagesize 16K --db.size.limit 8TB"
fi

if [ "${IPV6}" = "true" ]; then
Expand All @@ -93,4 +105,4 @@ fi

# Word splitting is desired for the command line parameters
# shellcheck disable=SC2086
exec "$@" ${__ipv6} ${__network} ${__prune} ${EL_EXTRAS}
exec "$@" ${__ipv6} ${__network} ${__prune} ${__db_params} ${EL_EXTRAS}
21 changes: 9 additions & 12 deletions ethd
Original file line number Diff line number Diff line change
Expand Up @@ -736,10 +736,6 @@ delete_reth() {


delete_erigon() {
# Enable this when Erigon v3 is out
if true; then
return 0
fi
# Check for Erigon
var="COMPOSE_FILE"
value=$(sed -n -e "s/^${var}=\(.*\)/\1/p" "${ENV_FILE}" || true)
Expand All @@ -754,19 +750,20 @@ delete_erigon() {
value=$(sed -n -e "s/^${var}=\(.*\)/\1/p" "${ENV_FILE}" || true)
# I do mean to match literally
# shellcheck disable=SC2076
if [[ ! ("${value}" =~ "v3" || "${value}" = "stable") ]]; then
# if [[ ! ("${value}" =~ "v3" || "${value}" = "latest" || "${value}" = "stable") ]]; then # No stable yet
if [[ ! ("${value}" =~ "v3" || "${value}" = "latest") ]]; then
return 0
fi

if [ -z "$(dodocker volume ls -q -f "name=erigon-el-data")" ]; then # No Erigon volume
if [ -z "$(dodocker volume ls -q -f "name=$(basename "$(realpath .)")[_-]erigon-el-data")" ]; then # No Erigon volume
return 0
fi

# https://discord.com/channels/687972960811745322/886550095749873666/1068994749480054866
# Detect Erigon v3 by files in snapshots/history
if [ -n "$(dodocker run --rm -v "$(dodocker volume ls -q -f "name=erigon-el-data")":"/var/lib/erigon" \
alpine:3 ls /var/lib/erigon/snapshots/history)" ]; then
return 0 # Files in snapshots/history means it's v3
# Detect Erigon v3 by directory caplin/latest
__erigon_v3=$(dodocker run --rm -v "$(dodocker volume ls -q -f "name=$(basename "$(realpath .)")[_-]erigon-el-data")":"/var/lib/erigon" \
alpine:3 sh -c 'if [ -d "/var/lib/erigon/caplin/latest" ]; then echo true; else echo false; fi')
if [ "$__erigon_v3" = "true" ]; then
return 0
fi

echo "Detected Erigon. For Erigon v3, it will need to be re-synced from scratch."
Expand All @@ -781,7 +778,7 @@ delete_erigon() {

echo "Stopping Erigon container"
docompose stop execution && docompose rm -f execution
dodocker volume rm "$(dodocker volume ls -q -f "name=erigon-el-data")"
dodocker volume rm "$(dodocker volume ls -q -f "name=$(basename "$(realpath .)")[_-]erigon-el-data")"
echo
echo "Erigon stopped and database deleted."
echo
Expand Down