Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic updates, add prints and variables #209

Merged
merged 1 commit into from
Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 50 additions & 36 deletions foundry/projects/local-private-network/deploy-local-network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,43 +89,49 @@ for i in $(seq 0 "$ACCOUNTS"); do
balance+=(' "'"${address[i]}"'": { "balance": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"}')
done

#ALLOC_CLEAN=$(echo ${ALLOC} | jq .)
EXTRA_DATA="0x3132333400000000000000000000000000000000000000000000000000000000${address[0]#0x}0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
JSON_VAL='{
"config": {
"chainId": '"$CHAINID"',
"homesteadBlock": 0,
"eip150Block": 0,
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"clique": {
"period": '"$PERIOD"',
"epoch": 3000
}
},
"difficulty": "0x1",
"gaslimit": "0xffffffffffff",
"extraData": "'"$EXTRA_DATA"'",
"alloc": {'"$balance"'}
}'
echo $JSON_VAL | jq . > $chaindir/config/genesis.json

geth 2>/dev/null --datadir "$chaindir" init "$chaindir/config/genesis.json"
if [[ ! -f "./genesis.json" ]]
then
EXTRA_DATA="0x3132333400000000000000000000000000000000000000000000000000000000${address[0]#0x}0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
JSON_VAL='{
"config": {
"chainId": '"$CHAINID"',
"homesteadBlock": 0,
"eip150Block": 0,
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"clique": {
"period": '"$PERIOD"',
"epoch": 3000
}
},
"difficulty": "0x1",
"gaslimit": "0xffffffffffff",
"extraData": "'"$EXTRA_DATA"'",
"alloc": {'"$balance"'}
}'
echo $JSON_VAL | jq . > $chaindir/config/genesis.json

geth 2>/dev/null --datadir "$chaindir" init "$chaindir/config/genesis.json"
else
echo "Using local genesis file"
geth 2>/dev/null --datadir "$chaindir" init "./genesis.json"
fi

export ETH_RPC_URL=http://$RPC_ADDRESS:$RPC_PORT

port=$((RPC_PORT + 30000))

geth version
echo >&2 "dapp-testnet: RPC URL: $ETH_RPC_URL"
echo >&2 "dapp-testnet: TCP port: $port"
echo >&2 "dapp-testnet: Chain ID: $CHAINID"
echo >&2 "dapp-testnet: Database: $chaindir"
echo >&2 "dapp-testnet: Geth log: $chaindir/geth.log"
echo >&2 "testnet: RPC URL: $ETH_RPC_URL"
echo >&2 "testnet: DB ADDRESS: $DB_HOST"
echo >&2 "testnet: TCP port: $port"
echo >&2 "testnet: Chain ID: $CHAINID"
echo >&2 "testnet: Database: $chaindir"
echo >&2 "testnet: Geth log: $chaindir/geth.log"

printf "%s\n" "${address[@]}" > "$chaindir/config/account"
echo "$ETH_RPC_URL" > "$chaindir/config/rpc-url"
Expand All @@ -145,24 +151,29 @@ set +m
# --statediff.db.type="$DB_TYPE" --statediff.db.driver="$DB_DRIVER" --statediff.waitforsync="$DB_WAIT_FOR_SYNC" \
# --ws --ws.addr="0.0.0.0" --unlock="$(IFS=,; echo "${address[*]}")" --password=<(exit) &

echo "Starting Geth with following flags"
geth \
2> >(tee "$chaindir/geth.log" | grep --line-buffered Success | sed 's/^/geth: /' >&2) \
--datadir "$chaindir" --networkid "$CHAINID" --port="$port" \
--mine --miner.threads=1 --allow-insecure-unlock \
--http --http.api "web3,eth,net,debug,personal,statediff" --http.corsdomain '*' --http.vhosts '*' --nodiscover \
--http --http.api "admin,debug,eth,miner,net,personal,txpool,web3,statediff" --http.corsdomain '*' --http.vhosts '*' --nodiscover \
--http.addr="$RPC_ADDRESS" --http.port="$RPC_PORT" --syncmode=full --gcmode=archive \
--statediff --statediff.db.host="$DB_HOST" --statediff.db.port="$DB_PORT" --statediff.db.user="$DB_USER" \
--statediff.db.password="$DB_PASSWORD" --statediff.db.name="$DB_NAME" \
--statediff.db.nodeid 1 --statediff.db.clientname test1 --statediff.writing="$DB_WRITE" \
--statediff.db.type="$DB_TYPE" --statediff.db.driver="$DB_DRIVER" \
--ws --ws.addr="0.0.0.0" --unlock="$(IFS=,; echo "${address[*]}")" --password=<(exit) &
--ws --ws.addr="0.0.0.0" --ws.origins '*' --ws.api=admin,debug,eth,miner,net,personal,txpool,web3 \
--nat=none --miner.gasprice 16000000000 --nat=none \
--unlock="$(IFS=,; echo "${address[*]}")" --password=<(exit) &

gethpid=$!
echo "Geth started"
echo "Geth PID: $gethpid"

clean() {
( set -x; kill -INT $gethpid; wait )
if [[ $SAVE ]]; then
echo >&2 "dapp-testnet: saving $gethdir/snapshots/$SAVE"
echo >&2 "testnet: saving $gethdir/snapshots/$SAVE"
mkdir -p "$gethdir/snapshots/$SAVE"
cp -r "$chaindir/keystore" "$gethdir/snapshots/$SAVE"
cp -r "$chaindir/config" "$gethdir/snapshots/$SAVE"
Expand All @@ -173,15 +184,18 @@ clean() {
}
trap clean EXIT

echo "Curling: $ETH_RPC_URL"
until curl -s "$ETH_RPC_URL"; do sleep 1; done

echo "Curling: $ETH_RPC_URL complete"
# UPDATE
#ETH_FROM=$(seth --rpc-url="$ETH_RPC_URL" rpc eth_coinbase)
#export ETH_FROM
export ETH_KEYSTORE=$chaindir/keystore
export ETH_PASSWORD=/dev/null
printf 'dapp-testnet: Account: %s (default)\n' "${address[0]}" >&2
printf 'testnet: Account: %s (default)\n' "${address[0]}" >&2

[[ "${#address[@]}" -gt 1 ]] && printf 'dapp-testnet: Account: %s\n' "${address[@]:1}" >&2
[[ "${#address[@]}" -gt 1 ]] && printf 'testnet: Account: %s\n' "${address[@]:1}" >&2

echo "Geth Start up completed!"
while true; do sleep 3600; done
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trap "exit 1" SIGINT SIGTERM
TMPDIR=$(mktemp -d)
/bin/bash deploy-local-network.sh --rpc-addr 0.0.0.0 --chain-id 4 --db-user $DB_USER --db-password $DB_PASSWORD --db-name $DB_NAME \
--db-host $DB_HOST --db-port $DB_PORT --db-write $DB_WRITE --dir "$TMPDIR" --address $ADDRESS \
--db-type $DB_TYPE --db-driver $DB_DRIVER --db-waitforsync $DB_WAIT_FOR_SYNC &
--db-type $DB_TYPE --db-driver $DB_DRIVER --db-waitforsync $DB_WAIT_FOR_SYNC --chain-id $CHAIN_ID &
echo "sleeping 90 sec"
# give it a few secs to start up
sleep 90
Expand Down