2021-03-23 11:52:25 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Startup script to initialize and boot a nimbus instance.
|
|
|
|
#
|
|
|
|
# This script assumes the following files:
|
|
|
|
# - `nimbus` binary is located in the filesystem root
|
|
|
|
# - `genesis.json` file is located in the filesystem root (mandatory)
|
|
|
|
# - `chain.rlp` file is located in the filesystem root (optional)
|
|
|
|
# - `blocks` folder is located in the filesystem root (optional)
|
|
|
|
# - `keys` folder is located in the filesystem root (optional)
|
|
|
|
#
|
|
|
|
# This script assumes the following environment variables:
|
|
|
|
#
|
2021-05-19 09:36:43 +00:00
|
|
|
# - [x] HIVE_BOOTNODE enode URL of the remote bootstrap node
|
2021-05-18 02:31:11 +00:00
|
|
|
# - [x] HIVE_NETWORK_ID network ID number to use for the eth protocol
|
2021-05-20 06:39:44 +00:00
|
|
|
# - [x] HIVE_CHAIN_ID chain ID is used in transaction signature process
|
2021-03-23 11:52:25 +00:00
|
|
|
# - [ ] HIVE_TESTNET whether testnet nonces (2^20) are needed
|
|
|
|
# - [ ] HIVE_NODETYPE sync and pruning selector (archive, full, light)
|
|
|
|
#
|
|
|
|
# Forks:
|
|
|
|
#
|
|
|
|
# - [x] HIVE_FORK_HOMESTEAD block number of the homestead hard-fork transition
|
|
|
|
# - [x] HIVE_FORK_DAO_BLOCK block number of the DAO hard-fork transition
|
|
|
|
# - [x] HIVE_FORK_DAO_VOTE whether the node support (or opposes) the DAO fork
|
|
|
|
# - [x] HIVE_FORK_TANGERINE block number of Tangerine Whistle transition
|
|
|
|
# - [x] HIVE_FORK_SPURIOUS block number of Spurious Dragon transition
|
|
|
|
# - [x] HIVE_FORK_BYZANTIUM block number for Byzantium transition
|
|
|
|
# - [x] HIVE_FORK_CONSTANTINOPLE block number for Constantinople transition
|
|
|
|
# - [x] HIVE_FORK_PETERSBURG block number for ConstantinopleFix/PetersBurg transition
|
|
|
|
# - [x] HIVE_FORK_ISTANBUL block number for Istanbul transition
|
|
|
|
# - [x] HIVE_FORK_MUIRGLACIER block number for Muir Glacier transition
|
|
|
|
# - [x] HIVE_FORK_BERLIN block number for Berlin transition
|
2021-06-28 02:01:18 +00:00
|
|
|
# - [x] HIVE_FORK_LONDON block number for London transition
|
2021-03-23 11:52:25 +00:00
|
|
|
#
|
|
|
|
# Clique PoA:
|
|
|
|
#
|
2021-08-02 12:41:39 +00:00
|
|
|
# - [x] HIVE_CLIQUE_PERIOD enables clique support. value is block time in seconds.
|
|
|
|
# - [x] HIVE_CLIQUE_PRIVATEKEY private key for clique mining
|
2021-03-23 11:52:25 +00:00
|
|
|
#
|
|
|
|
# Other:
|
|
|
|
#
|
2021-08-02 12:41:39 +00:00
|
|
|
# - [x] HIVE_MINER enable mining. value is coinbase address.
|
2021-03-23 11:52:25 +00:00
|
|
|
# - [ ] HIVE_MINER_EXTRA extra-data field to set for newly minted blocks
|
|
|
|
# - [ ] HIVE_SKIP_POW if set, skip PoW verification during block import
|
2021-05-18 02:31:11 +00:00
|
|
|
# - [x] HIVE_LOGLEVEL client loglevel (0-5)
|
|
|
|
# - [x] HIVE_GRAPHQL_ENABLED enables graphql on port 8545
|
2021-03-23 11:52:25 +00:00
|
|
|
|
|
|
|
# Immediately abort the script on any error encountered
|
|
|
|
set -e
|
|
|
|
|
|
|
|
nimbus=/usr/bin/nimbus
|
2021-05-06 04:18:21 +00:00
|
|
|
FLAGS="--prune:archive --nat:0.0.0.0"
|
2021-03-23 11:52:25 +00:00
|
|
|
|
|
|
|
if [ "$HIVE_LOGLEVEL" != "" ]; then
|
2021-03-31 07:22:30 +00:00
|
|
|
FLAGS="$FLAGS --log-level:DEBUG"
|
2021-03-23 11:52:25 +00:00
|
|
|
fi
|
|
|
|
|
2021-05-19 09:36:43 +00:00
|
|
|
# It doesn't make sense to dial out, use only a pre-set bootnode.
|
|
|
|
if [ "$HIVE_BOOTNODE" != "" ]; then
|
|
|
|
FLAGS="$FLAGS --bootnodes:$HIVE_BOOTNODE"
|
|
|
|
fi
|
|
|
|
|
2021-05-20 06:39:44 +00:00
|
|
|
if [ "$HIVE_NETWORK_ID" != "" ]; then
|
|
|
|
FLAGS="$FLAGS --networkid:$HIVE_NETWORK_ID"
|
|
|
|
fi
|
|
|
|
|
2021-08-02 12:41:39 +00:00
|
|
|
if [ "$HIVE_CLIQUE_PRIVATEKEY" != "" ]; then
|
2021-08-09 01:35:54 +00:00
|
|
|
# -n will prevent newline when echoing something
|
|
|
|
echo -n "$HIVE_CLIQUE_PRIVATEKEY" > private.key
|
|
|
|
FLAGS="$FLAGS --import-key:private.key"
|
2021-08-02 12:41:39 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$HIVE_MINER" != "" ]; then
|
|
|
|
FLAGS="$FLAGS --engine-signer:$HIVE_MINER"
|
|
|
|
fi
|
|
|
|
|
2021-05-14 07:56:21 +00:00
|
|
|
# Configure the genesis chain and use it as start block and dump it to stdout
|
2021-03-23 11:52:25 +00:00
|
|
|
echo "Supplied genesis state:"
|
2021-05-14 07:56:21 +00:00
|
|
|
jq -f /mapper.jq /genesis.json | tee /genesis-start.json
|
|
|
|
FLAGS="$FLAGS --customnetwork:/genesis-start.json"
|
2021-03-23 11:52:25 +00:00
|
|
|
|
|
|
|
# Don't immediately abort, some imports are meant to fail
|
|
|
|
set +e
|
|
|
|
|
2021-04-28 15:13:50 +00:00
|
|
|
# Load the test chain if present
|
|
|
|
echo "Loading initial blockchain..."
|
|
|
|
if [ -f /chain.rlp ]; then
|
2021-05-18 02:31:11 +00:00
|
|
|
$nimbus $FLAGS --import:/chain.rlp
|
2021-04-28 15:13:50 +00:00
|
|
|
else
|
2021-05-18 02:31:11 +00:00
|
|
|
echo "Warning: chain.rlp not found."
|
2021-04-28 15:13:50 +00:00
|
|
|
fi
|
|
|
|
|
2021-03-23 11:52:25 +00:00
|
|
|
# Load the remainder of the test chain
|
|
|
|
echo "Loading remaining individual blocks..."
|
|
|
|
if [ -d /blocks ]; then
|
2021-05-18 02:31:11 +00:00
|
|
|
(cd /blocks && cat `ls | sort -n` > blocks.rlp && $nimbus $FLAGS --import:blocks.rlp)
|
2021-03-23 11:52:25 +00:00
|
|
|
else
|
2021-05-18 02:31:11 +00:00
|
|
|
echo "Warning: blocks folder not found."
|
2021-03-23 11:52:25 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Configure RPC.
|
2021-04-28 15:13:50 +00:00
|
|
|
if [ "$HIVE_GRAPHQL_ENABLED" != "" ]; then
|
|
|
|
FLAGS="$FLAGS --graphql --graphqlbind:0.0.0.0:8545"
|
|
|
|
else
|
|
|
|
FLAGS="$FLAGS --rpc --rpcapi:eth,debug --rpcbind:0.0.0.0:8545"
|
2021-08-02 12:41:39 +00:00
|
|
|
FLAGS="$FLAGS --ws --wsapi:eth,debug --wsbind:0.0.0.0:8546"
|
2021-04-28 15:13:50 +00:00
|
|
|
fi
|
2021-03-23 11:52:25 +00:00
|
|
|
|
|
|
|
echo "Running nimbus with flags $FLAGS"
|
|
|
|
$nimbus $FLAGS
|