Skip to content

Commit e1a5a93

Browse files
committed
Support Nethermind FlatDB
1 parent fb928a4 commit e1a5a93

4 files changed

Lines changed: 40 additions & 8 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, and Flat requires a node with 48GB of RAM. FlatInTrie is less memory intensive.
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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2781,6 +2781,14 @@ prune-nethermind() {
27812781
exit 1
27822782
fi
27832783

2784+
# Check for FlatDB
2785+
var="NETHERMIND_FLATDB"
2786+
__get_value_from_env "${var}" "${__env_file}" "__value"
2787+
if [[ -n "${__value}" ]]; then
2788+
echo "Nethermind is configured for FlatDB, which cannot be pruned. Aborting."
2789+
exit 1
2790+
fi
2791+
27842792
__get_docker_free_space
27852793

27862794
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+
- NETHERMIND_FLATDB=${NETHERMIND_FLATDB:-}
3233
- NETWORK=${NETWORK}
3334
# For Grandine plugin
3435
- COMPOSE_FILE=${COMPOSE_FILE}
@@ -75,16 +76,13 @@ services:
7576
- 0.0.0.0
7677
- --JsonRpc.EnginePort
7778
- ${EE_PORT:-8551}
78-
- --JsonRpc.AdditionalRpcUrls=http://127.0.0.1:1337|http|admin
7979
- --JsonRpc.JwtSecretFile=/var/lib/nethermind/ee-secret/jwtsecret
8080
- --Metrics.Enabled
8181
- "true"
8282
- --Metrics.ExposeHost
8383
- 0.0.0.0
8484
- --Metrics.ExposePort
8585
- "6060"
86-
- --Pruning.FullPruningCompletionBehavior
87-
- AlwaysShutdown
8886
- --log
8987
- ${LOG_LEVEL}
9088
labels:

nethermind/docker-entrypoint.sh

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,38 @@ 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 "${NETHERMIND_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+
;;
90+
flatintrie)
91+
echo "Enabling Nethermind FlatDB with Layout FlatInTrie"
92+
__flat="--FlatDb.Enabled=true --FlatDb.ImportFromPruningTrieState=true --FlatDb.Layout=FlatInTrie"
93+
;;
94+
*)
95+
__flat=""
96+
echo "Unknown value ${NETHERMIND_FLATBD} for \"NETHERMIND_FLATDB\". Continuing without FlatDB."
97+
;;
98+
esac
99+
fi
100+
101+
__prune=""
102+
if [[ ! "${NETWORK}" =~ ^https?:// && "${NODE_TYPE}" != "archive" && -z "${__flat}" ]]; then # Only configure prune parameters for named networks
80103
memtotal=$(awk '/MemTotal/ {printf "%d", int($2/1024/1024)}' /proc/meminfo)
81104
parallel=$(($(nproc)/4))
82105
if [[ "${parallel}" -lt 2 ]]; then
83106
parallel=2
84107
fi
85-
__prune="--Pruning.FullPruningMaxDegreeOfParallelism=${parallel}"
108+
__prune="--Pruning.FullPruningMaxDegreeOfParallelism=${parallel} --Pruning.FullPruningCompletionBehavior=AlwaysShutdown --JsonRpc.AdditionalRpcUrls=http://127.0.0.1:1337|http|admin"
86109
if [[ "${AUTOPRUNE_NM}" = true ]]; then
87-
__prune="${__prune} --Pruning.FullPruningTrigger=VolumeFreeSpace"
110+
__prune+=" --Pruning.FullPruningTrigger=VolumeFreeSpace"
88111
if [[ "${NETWORK}" =~ (mainnet|gnosis) ]]; then
89112
__prune+=" --Pruning.FullPruningThresholdMb=375810"
90113
else
@@ -318,4 +341,4 @@ set -- "${__args[@]}"
318341

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

0 commit comments

Comments
 (0)