Skip to content

Commit a42ff9a

Browse files
authored
Support Nethermind FlatDB (#2568)
1 parent f739ca1 commit a42ff9a

4 files changed

Lines changed: 49 additions & 9 deletions

File tree

default.env

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@ EL_NODE_TYPE=pre-merge-expiry
258258
# empty or "false" disables it, and any other string is assumed to be
259259
# exact parameters for Reth's "download" function
260260
RETH_SNAPSHOT=
261+
# Nethermind FlatDB. Possible values empty (don't use FlatDB), flat, or flatintrie, see https://github.com/NethermindEth/nethermind/releases/tag/1.37.0
262+
# FlatDB cannot be used with an archive node.
263+
NETHERMIND_FLATDB=
261264
# EraE URL, see https://github.com/eth-clients/e2store-format-specs/ and https://ethpandaops.io/data/history/
262265
# If this URL is provided, an EL that supports EraE import will use it when fresh syncing
263266
ERA_URL=
@@ -501,4 +504,4 @@ DOCKER_ROOT=/var/lib/docker
501504
DOCKER_SOCK=/var/run/docker.sock
502505

503506
# Used by ethd update - please do not adjust
504-
ENV_VERSION=56
507+
ENV_VERSION=57

ethd

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -Eeuo pipefail
55
__project_name="Eth Docker"
66
__app_name="Ethereum node"
77
__sample_service="consensus"
8-
__min_env_version=56
8+
__min_env_version=57
99
__target_pg=18
1010
__current_docker=29
1111
__docker_exe="docker"
@@ -2948,6 +2948,14 @@ prune-nethermind() {
29482948
exit 1
29492949
fi
29502950

2951+
# Check for FlatDB
2952+
var="NETHERMIND_FLATDB"
2953+
__get_value_from_env "${var}" "${__env_file}" "__value"
2954+
if [[ -n "${__value}" ]]; then
2955+
echo "Nethermind is configured for FlatDB, which need not and cannot be pruned. Aborting."
2956+
exit 1
2957+
fi
2958+
29512959
__get_docker_free_space
29522960

29532961
var="NETWORK"

nethermind.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ services:
2929
- EL_EXTRAS=${EL_EXTRAS:-}
3030
- NODE_TYPE=${EL_NODE_TYPE:-pre-merge-expiry}
3131
- AUTOPRUNE_NM=${AUTOPRUNE_NM:-true}
32+
- NM_FLATDB=${NETHERMIND_FLATDB:-}
3233
- NETWORK=${NETWORK}
3334
# For Grandine plugin
3435
- COMPOSE_FILE=${COMPOSE_FILE}
@@ -77,16 +78,13 @@ services:
7778
- 0.0.0.0
7879
- --JsonRpc.EnginePort
7980
- ${EE_PORT:-8551}
80-
- --JsonRpc.AdditionalRpcUrls=http://127.0.0.1:1337|http|admin
8181
- --JsonRpc.JwtSecretFile=/var/lib/nethermind/ee-secret/jwtsecret
8282
- --Metrics.Enabled
8383
- "true"
8484
- --Metrics.ExposeHost
8585
- 0.0.0.0
8686
- --Metrics.ExposePort
8787
- "6060"
88-
- --Pruning.FullPruningCompletionBehavior
89-
- AlwaysShutdown
9088
- --log
9189
- ${LOG_LEVEL}
9290
labels:

nethermind/docker-entrypoint.sh

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ if [[ -O /var/lib/nethermind/ee-secret/jwtsecret ]]; then
4949
chmod 666 /var/lib/nethermind/ee-secret/jwtsecret
5050
fi
5151

52+
# This will be set by custom network code or named network node type code
53+
__prune=""
54+
5255
if [[ "${NETWORK}" =~ ^https?:// ]]; then
5356
echo "Custom testnet at ${NETWORK}"
5457
repo=$(awk -F'/tree/' '{print $1}' <<< "${NETWORK}")
@@ -76,15 +79,39 @@ else
7679
__network="--config ${NETWORK}"
7780
fi
7881

79-
if [[ ! "${NETWORK}" =~ ^https?:// && ! "${NODE_TYPE}" = "archive" ]]; then # Only configure prune parameters for named networks
82+
if [[ "${NODE_TYPE}" = "archive" ]]; then
83+
__flat=""
84+
else
85+
case "${NM_FLATDB}" in
86+
"")
87+
__flat=""
88+
;;
89+
flat)
90+
echo "Enabling Nethermind FlatDB with Layout Flat"
91+
#__flat="--FlatDb.Enabled=true --FlatDb.ImportFromPruningTrieState=true"
92+
__flat="--FlatDb.Enabled=true"
93+
;;
94+
flatintrie)
95+
echo "Enabling Nethermind FlatDB with Layout FlatInTrie"
96+
#__flat="--FlatDb.Enabled=true --FlatDb.ImportFromPruningTrieState=true --FlatDb.Layout=FlatInTrie"
97+
__flat="--FlatDb.Enabled=true --FlatDb.Layout=FlatInTrie"
98+
;;
99+
*)
100+
__flat=""
101+
echo "Unknown value ${NM_FLATDB} for \"NETHERMIND_FLATDB\". Continuing without FlatDB."
102+
;;
103+
esac
104+
fi
105+
106+
if [[ ! "${NETWORK}" =~ ^https?:// && "${NODE_TYPE}" != "archive" && -z "${__flat}" ]]; then # Only configure prune parameters for named networks, non-archive and HalfPath DB
80107
memtotal=$(awk '/MemTotal/ {printf "%d", int($2/1024/1024)}' /proc/meminfo)
81108
parallel=$(($(nproc)/4))
82109
if [[ "${parallel}" -lt 2 ]]; then
83110
parallel=2
84111
fi
85-
__prune="--Pruning.FullPruningMaxDegreeOfParallelism=${parallel}"
112+
__prune="--Pruning.FullPruningMaxDegreeOfParallelism=${parallel} --Pruning.FullPruningCompletionBehavior=AlwaysShutdown --JsonRpc.AdditionalRpcUrls=http://127.0.0.1:1337|http|admin"
86113
if [[ "${AUTOPRUNE_NM}" = true ]]; then
87-
__prune="${__prune} --Pruning.FullPruningTrigger=VolumeFreeSpace"
114+
__prune+=" --Pruning.FullPruningTrigger=VolumeFreeSpace"
88115
if [[ "${NETWORK}" =~ (mainnet|gnosis) ]]; then
89116
__prune+=" --Pruning.FullPruningThresholdMb=375810"
90117
else
@@ -153,6 +180,10 @@ esac
153180

154181
echo "Using pruning parameters:"
155182
echo "${__prune}"
183+
if [[ -n "${__flat}" ]]; then
184+
echo "Using FlatDB parameters:"
185+
echo "${__flat}"
186+
fi
156187

157188
# New or old datadir
158189
if [[ -d /var/lib/nethermind-og/nethermind_db ]]; then
@@ -318,4 +349,4 @@ set -- "${__args[@]}"
318349

319350
# Word splitting is desired for the command line parameters
320351
# shellcheck disable=SC2086
321-
exec "$@" ${__datadir} ${__network} ${__prune} ${__grandine} ${EL_EXTRAS}
352+
exec "$@" ${__datadir} ${__network} ${__prune} ${__flat} ${__grandine} ${EL_EXTRAS}

0 commit comments

Comments
 (0)