Skip to content

Commit a87df79

Browse files
committed
Support Nethermind FlatDB
1 parent 0f254a9 commit a87df79

4 files changed

Lines changed: 47 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. flat works well with 48GB of RAM, flatintrie appears to work well with 24GB.
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=
@@ -494,4 +497,4 @@ DOCKER_ROOT=/var/lib/docker
494497
DOCKER_SOCK=/var/run/docker.sock
495498

496499
# Used by ethd update - please do not adjust
497-
ENV_VERSION=55
500+
ENV_VERSION=56

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=55
8+
__min_env_version=56
99
__docker_exe="docker"
1010
__old_docker=0
1111
__docker_sudo=""
@@ -2856,6 +2856,14 @@ prune-nethermind() {
28562856
exit 1
28572857
fi
28582858

2859+
# Check for FlatDB
2860+
var="NETHERMIND_FLATDB"
2861+
__get_value_from_env "${var}" "${__env_file}" "__value"
2862+
if [[ -n "${__value}" ]]; then
2863+
echo "Nethermind is configured for FlatDB, which need not and cannot be pruned. Aborting."
2864+
exit 1
2865+
fi
2866+
28592867
__get_docker_free_space
28602868

28612869
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: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,40 @@ else
7676
__network="--config ${NETWORK}"
7777
fi
7878

79-
if [[ ! "${NETWORK}" =~ ^https?:// && ! "${NODE_TYPE}" = "archive" ]]; then # Only configure prune parameters for named networks
79+
if [[ "${NODE_TYPE}" = "archive" ]]; then
80+
__flat=""
81+
else
82+
case "${NM_FLATDB}" in
83+
"")
84+
__flat=""
85+
;;
86+
flat)
87+
echo "Enabling Nethermind FlatDB with Layout Flat"
88+
#__flat="--FlatDb.Enabled=true --FlatDb.ImportFromPruningTrieState=true"
89+
__flat="--FlatDb.Enabled=true"
90+
;;
91+
flatintrie)
92+
echo "Enabling Nethermind FlatDB with Layout FlatInTrie"
93+
#__flat="--FlatDb.Enabled=true --FlatDb.ImportFromPruningTrieState=true --FlatDb.Layout=FlatInTrie"
94+
__flat="--FlatDb.Enabled=true --FlatDb.Layout=FlatInTrie"
95+
;;
96+
*)
97+
__flat=""
98+
echo "Unknown value ${NM_FLATBD} for \"NETHERMIND_FLATDB\". Continuing without FlatDB."
99+
;;
100+
esac
101+
fi
102+
103+
__prune=""
104+
if [[ ! "${NETWORK}" =~ ^https?:// && "${NODE_TYPE}" != "archive" && -z "${__flat}" ]]; then # Only configure prune parameters for named networks
80105
memtotal=$(awk '/MemTotal/ {printf "%d", int($2/1024/1024)}' /proc/meminfo)
81106
parallel=$(($(nproc)/4))
82107
if [[ "${parallel}" -lt 2 ]]; then
83108
parallel=2
84109
fi
85-
__prune="--Pruning.FullPruningMaxDegreeOfParallelism=${parallel}"
110+
__prune="--Pruning.FullPruningMaxDegreeOfParallelism=${parallel} --Pruning.FullPruningCompletionBehavior=AlwaysShutdown --JsonRpc.AdditionalRpcUrls=http://127.0.0.1:1337|http|admin"
86111
if [[ "${AUTOPRUNE_NM}" = true ]]; then
87-
__prune="${__prune} --Pruning.FullPruningTrigger=VolumeFreeSpace"
112+
__prune+=" --Pruning.FullPruningTrigger=VolumeFreeSpace"
88113
if [[ "${NETWORK}" =~ (mainnet|gnosis) ]]; then
89114
__prune+=" --Pruning.FullPruningThresholdMb=375810"
90115
else
@@ -153,6 +178,10 @@ esac
153178

154179
echo "Using pruning parameters:"
155180
echo "${__prune}"
181+
if [[ -n "${__flat}" ]]; then
182+
echo "Using FlatDB parameters:"
183+
echo "${__flat}"
184+
fi
156185

157186
# New or old datadir
158187
if [[ -d /var/lib/nethermind-og/nethermind_db ]]; then
@@ -318,4 +347,4 @@ set -- "${__args[@]}"
318347

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

0 commit comments

Comments
 (0)