From 87b2e388a39209c464587cbab439a8016b256050 Mon Sep 17 00:00:00 2001 From: spencer Date: Tue, 24 Oct 2023 16:51:53 -0600 Subject: [PATCH] clients: only output full genesis file at high log levels (#927) * clients: Trim genesis output for low log levels. * clients: Specific echo for trimmed genesis output. --- clients/besu/besu.sh | 16 +++++++++++++--- clients/erigon/erigon.sh | 11 ++++++++--- clients/ethereumjs/ethereumjs.sh | 13 ++++++++----- clients/go-ethereum/geth.sh | 11 ++++++++--- clients/nethermind/nethermind.sh | 11 +++++++++-- clients/nimbus-el/nimbus.sh | 14 +++++++++++--- clients/reth/reth.sh | 11 ++++++++--- 7 files changed, 65 insertions(+), 22 deletions(-) diff --git a/clients/besu/besu.sh b/clients/besu/besu.sh index 31dad9ed9b..28f46f3d59 100644 --- a/clients/besu/besu.sh +++ b/clients/besu/besu.sh @@ -63,9 +63,19 @@ esac FLAGS="--logging=$LOG --data-storage-format=BONSAI" # Configure the chain. -jq -f /mapper.jq /genesis.json > /besugenesis.json -echo -n "Genesis: "; cat /besugenesis.json -FLAGS="$FLAGS --genesis-file=/besugenesis.json " +mv /genesis.json /genesis-input.json +jq -f /mapper.jq /genesis-input.json > /genesis.json +FLAGS="$FLAGS --genesis-file=/genesis.json " + +# Dump genesis. +if [ "$HIVE_LOGLEVEL" -lt 4 ]; then + echo "Supplied genesis state (trimmed, use --sim.loglevel 4 or 5 for full output):" + jq 'del(.alloc[] | select(.balance == "0x123450000000000000000"))' /genesis.json +else + echo "Supplied genesis state:" + cat /genesis.json +fi + # Enable experimental 'berlin' hard-fork features if configured. #if [ -n "$HIVE_FORK_BERLIN" ]; then diff --git a/clients/erigon/erigon.sh b/clients/erigon/erigon.sh index 92e974316a..a942935417 100644 --- a/clients/erigon/erigon.sh +++ b/clients/erigon/erigon.sh @@ -67,9 +67,14 @@ fi mv /genesis.json /genesis-input.json jq -f /mapper.jq /genesis-input.json > /genesis.json -# Dump genesis -echo "Supplied genesis state:" -cat /genesis.json +# Dump genesis. +if [ "$HIVE_LOGLEVEL" -lt 4 ]; then + echo "Supplied genesis state (trimmed, use --sim.loglevel 4 or 5 for full output):" + jq 'del(.alloc[] | select(.balance == "0x123450000000000000000"))' /genesis.json +else + echo "Supplied genesis state:" + cat /genesis.json +fi echo "Command flags till now:" echo $FLAGS diff --git a/clients/ethereumjs/ethereumjs.sh b/clients/ethereumjs/ethereumjs.sh index a818ebb6d3..f27cc9970c 100644 --- a/clients/ethereumjs/ethereumjs.sh +++ b/clients/ethereumjs/ethereumjs.sh @@ -51,14 +51,18 @@ set -e ethereumjs="node /ethereumjs-monorepo/packages/client/dist/bin/cli.js" FLAGS="--gethGenesis ./genesis.json --rpc --rpcEngine --saveReceipts --rpcAddr 0.0.0.0 --rpcEngineAddr 0.0.0.0 --rpcEnginePort 8551 --ws false --logLevel debug --rpcDebug --isSingleNode" - # Configure the chain. mv /genesis.json /genesis-input.json jq -f /mapper.jq /genesis-input.json > /genesis.json -# Dump genesis -echo "Supplied genesis state:" -cat /genesis.json +# Dump genesis. +if [ "$HIVE_LOGLEVEL" -lt 4 ]; then + echo "Supplied genesis state (trimmed, use --sim.loglevel 4 or 5 for full output):" + jq 'del(.alloc[] | select(.balance == "0x123450000000000000000"))' /genesis.json +else + echo "Supplied genesis state:" + cat /genesis.json +fi # Import clique signing key. if [ "$HIVE_CLIQUE_PRIVATEKEY" != "" ]; then @@ -75,7 +79,6 @@ if [ "$HIVE_TERMINAL_TOTAL_DIFFICULTY" != "" ]; then FLAGS="$FLAGS --jwt-secret ./jwtsecret" fi - # Load the test chain if present echo "Loading initial blockchain..." if [ -f /chain.rlp ]; then diff --git a/clients/go-ethereum/geth.sh b/clients/go-ethereum/geth.sh index 92cdd37db0..38204d4a73 100644 --- a/clients/go-ethereum/geth.sh +++ b/clients/go-ethereum/geth.sh @@ -93,9 +93,14 @@ fi mv /genesis.json /genesis-input.json jq -f /mapper.jq /genesis-input.json > /genesis.json -# Dump genesis -echo "Supplied genesis state:" -cat /genesis.json +# Dump genesis. +if [ "$HIVE_LOGLEVEL" -lt 4 ]; then + echo "Supplied genesis state (trimmed, use --sim.loglevel 4 or 5 for full output):" + jq 'del(.alloc[] | select(.balance == "0x123450000000000000000"))' /genesis.json +else + echo "Supplied genesis state:" + cat /genesis.json +fi # Initialize the local testchain with the genesis state echo "Initializing database with genesis state..." diff --git a/clients/nethermind/nethermind.sh b/clients/nethermind/nethermind.sh index fe6418110c..e65bb44736 100644 --- a/clients/nethermind/nethermind.sh +++ b/clients/nethermind/nethermind.sh @@ -57,9 +57,16 @@ fi # Generate the genesis and chainspec file. mkdir -p /chainspec -echo "Supplied genesis state:" jq -f /mapper.jq /genesis.json > /chainspec/test.json -jq . /chainspec/test.json + +# Dump genesis. +if [ "$HIVE_LOGLEVEL" -lt 4 ]; then + echo "Supplied genesis state (trimmed, use --sim.loglevel 4 or 5 for full output):" + jq 'del(.accounts[] | select(.balance == "0x123450000000000000000" or has("builtin")))' /chainspec/test.json +else + echo "Supplied genesis state:" + cat /chainspec/test.json +fi # Generate the config file. mkdir /configs diff --git a/clients/nimbus-el/nimbus.sh b/clients/nimbus-el/nimbus.sh index ea3cc9dac4..94bdeebb84 100644 --- a/clients/nimbus-el/nimbus.sh +++ b/clients/nimbus-el/nimbus.sh @@ -81,11 +81,19 @@ if [ "$HIVE_CLIQUE_PRIVATEKEY" != "" ]; then fi fi -# Configure the genesis chain and use it as start block and dump it to stdout -echo "Supplied genesis state:" -jq -f /mapper.jq /genesis.json | tee /genesis-start.json +# Configure the chain. +jq -f /mapper.jq /genesis.json > /genesis-start.json FLAGS="$FLAGS --custom-network:/genesis-start.json" +# Dump genesis. +if [ "$HIVE_LOGLEVEL" -lt 4 ]; then + echo "Supplied genesis state (trimmed, use --sim.loglevel 4 or 5 for full output):" + jq 'del(.genesis.alloc[] | select(.balance == "0x123450000000000000000"))' /genesis-start.json +else + echo "Supplied genesis state:" + cat /genesis-start.json +fi + # Don't immediately abort, some imports are meant to fail set +e diff --git a/clients/reth/reth.sh b/clients/reth/reth.sh index a643f4acc0..6adf995d4b 100644 --- a/clients/reth/reth.sh +++ b/clients/reth/reth.sh @@ -66,9 +66,14 @@ FLAGS="$FLAGS --datadir /reth-hive-datadir" mv /genesis.json /genesis-input.json jq -f /mapper.jq /genesis-input.json > /genesis.json -# Dump genesis -echo "Supplied genesis state:" -cat /genesis.json +# Dump genesis. +if [ "$HIVE_LOGLEVEL" -lt 4 ]; then + echo "Supplied genesis state (trimmed, use --sim.loglevel 4 or 5 for full output):" + jq 'del(.alloc[] | select(.balance == "0x123450000000000000000"))' /genesis.json +else + echo "Supplied genesis state:" + cat /genesis.json +fi echo "Command flags till now:" echo $FLAGS