Skip to content

Commit

Permalink
Nethermind path state
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickdowne committed Jun 18, 2024
1 parent 50bd12d commit 78f61b0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 19 deletions.
13 changes: 11 additions & 2 deletions ethd
Original file line number Diff line number Diff line change
Expand Up @@ -454,15 +454,17 @@ check_disk_space() {
echo "It should currently be auto-pruning, check logs with \"$__me logs -f --tail 500 execution | grep \
Full\". Free space:"
else
echo "If the below reads above ${__safe_prune} GiB free, prune it with \"$__me prune-nethermind\""
echo "You might be able to resync Nethermind for path storage if you haven't done so already, with \"$__me resync-execution\"."
echo "Also verify the amount of space your consensus layer client takes, and resync it as needed."
fi
echo
__display_docker_dir
__display_docker_volumes
elif [[ "${value}" =~ "geth.yml" ]] && [[ "${__free_space}" -lt 104857600 ]]; then
echo
echo "You are running Geth and have less than 100 GiB of free disk space."
echo "You may resync from scratch to use PBSS and slow on-disk DB growth, with \"$__me resync-execution\"."
echo "You may resync from scratch to use PBSS and slow on-disk DB growth, if you haven't done so already, with \"$__me resync-execution\"."
echo "Also verify the amount of space your consensus layer client takes, and resync it as needed."
echo
__display_docker_dir
__display_docker_volumes
Expand Down Expand Up @@ -1589,6 +1591,12 @@ prune-nethermind() {
var="NETWORK"
NETWORK=$(sed -n -e "s/^${var}=\(.*\)/\1/p" "${ENV_FILE}" || true)

if [ -n "$(dodocker run --rm -v "$(dodocker volume ls -q -f "name=nm-eth1-data")":"/var/lib/nethermind" \
alpine:3 ls "/var/lib/nethermind/nethermind_db/${NETWORK}/pathState")" ]; then
echo "This Nethermind uses path-based storage. Manual pruning is not required."
return 0
fi

if [ "${NETWORK}" = "mainnet" ] || [ "${NETWORK}" = "gnosis" ]; then
__min_free=262144000
__min_gib=250
Expand Down Expand Up @@ -1649,6 +1657,7 @@ prune-nethermind() {
echo "Nethermind should auto-prune below ${threshold} GiB free. Check logs with \"$__me logs -f --tail 500 \
execution | grep Full\" to see whether it is."
fi
echo "Instead of pruning, consider resyncing Nethermind to use path-based storage, with \"$__me resync-execution\"."
read -rp "WARNING - this will prune Nethermind's database in the background. Do you wish to continue? (No/Yes) " yn
case $yn in
[Yy][Ee][Ss] ) break;;
Expand Down
41 changes: 24 additions & 17 deletions nethermind/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,33 @@ if [ "${ARCHIVE_NODE}" = "true" ]; then
echo "Nethermind archive node without pruning"
__prune="--Sync.DownloadBodiesInFastSync=false --Sync.DownloadReceiptsInFastSync=false --Sync.FastSync=false --Sync.SnapSync=false --Sync.FastBlocks=false --Pruning.Mode=None --Sync.PivotNumber=0"
else
__parallel=$(($(nproc)/4))
if [ "${__parallel}" -lt 2 ]; then
__parallel=2
fi
__prune="--Pruning.FullPruningMaxDegreeOfParallelism=${__parallel}"
if [ "${AUTOPRUNE_NM}" = true ]; then
__prune="${__prune} --Pruning.FullPruningTrigger=VolumeFreeSpace"
if [ "${NETWORK}" = "mainnet" ] || [ "${NETWORK}" = "gnosis" ]; then
__prune="${__prune} --Pruning.FullPruningThresholdMb=375810"
else
__prune="${__prune} --Pruning.FullPruningThresholdMb=51200"
# Fresh DB or already path based storage
if [[ ! -d "/var/lib/nethermind/nethermind_db/${NETWORK}" || -d "/var/lib/nethermind/nethermind_db/${NETWORK}/pathState" ]]; then
__prune=""
else # Hash, set pruning parameters
__parallel=$(($(nproc)/4))
if [ "${__parallel}" -lt 2 ]; then
__parallel=2
fi
fi
if [ "${__memtotal}" -ge 30 ]; then
__prune="--Pruning.FullPruningMaxDegreeOfParallelism=${__parallel}"
if [ "${AUTOPRUNE_NM}" = true ]; then
__prune="${__prune} --Pruning.FullPruningTrigger=VolumeFreeSpace"
if [ "${NETWORK}" = "mainnet" ] || [ "${NETWORK}" = "gnosis" ]; then
__prune="${__prune} --Pruning.FullPruningThresholdMb=375810"
else
__prune="${__prune} --Pruning.FullPruningThresholdMb=51200"
fi
fi
if [ "${__memtotal}" -ge 30 ]; then
# Investigating instability
#__prune="${__prune} --Pruning.CacheMb=4096 --Pruning.FullPruningMemoryBudgetMb=16384 --Init.StateDbKeyScheme=HalfPath"
__prune="${__prune} --Pruning.FullPruningMemoryBudgetMb=16384 --Init.StateDbKeyScheme=HalfPath"
#__prune="${__prune} --Pruning.CacheMb=4096 --Pruning.FullPruningMemoryBudgetMb=16384"
__prune="${__prune} --Pruning.FullPruningMemoryBudgetMb=16384"
fi
fi
if [ -n "${__prune}" ]; then
echo "Using pruning parameters:"
echo "${__prune}"
fi
echo "Using pruning parameters:"
echo "${__prune}"
fi

# Word splitting is desired for the command line parameters
Expand Down

0 comments on commit 78f61b0

Please sign in to comment.