Skip to content

Commit

Permalink
clients: only output full genesis file at high log levels (#927)
Browse files Browse the repository at this point in the history
* clients: Trim genesis output for low log levels.

* clients: Specific echo for trimmed genesis output.
  • Loading branch information
spencer-tb authored Oct 24, 2023
1 parent b18f515 commit 87b2e38
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 22 deletions.
16 changes: 13 additions & 3 deletions clients/besu/besu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions clients/erigon/erigon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 8 additions & 5 deletions clients/ethereumjs/ethereumjs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
11 changes: 8 additions & 3 deletions clients/go-ethereum/geth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
Expand Down
11 changes: 9 additions & 2 deletions clients/nethermind/nethermind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions clients/nimbus-el/nimbus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 8 additions & 3 deletions clients/reth/reth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 87b2e38

Please sign in to comment.