Skip to content

Commit

Permalink
Changes to work with local Metamask wallet.
Browse files Browse the repository at this point in the history
So far works with Geth
  • Loading branch information
hmel committed Jun 26, 2022
1 parent a351f5a commit 9d0be3d
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 28 deletions.
23 changes: 15 additions & 8 deletions scripts/launch_local_testnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

set -eu

BASEDIR="$(dirname "${BASH_SOURCE[0]}")"

cd "$(dirname "${BASH_SOURCE[0]}")"/..


Expand Down Expand Up @@ -426,17 +428,20 @@ GETH_NUM_NODES="${NUM_NODES}"
NIMBUSEL_NUM_NODES="${NUM_NODES}"

if [[ "${RUN_GETH}" == "1" ]]; then
if [[ ! -e "${GETH_BINARY}" && "${DL_GETH}" == "1" ]]; then
log "Downloading geth ..."
download_geth
else
echo "Missing geth executable"
exit 1
if [[ ! -e "${GETH_BINARY}" ]]; then
if [[ "${DL_GETH}" == "1" ]]; then
log "Downloading geth ..."
download_geth
else
echo "Missing geth executable"
exit 1
fi
fi

log "Starting ${GETH_NUM_NODES} Geth Nodes ..."
. "./scripts/start_geth_nodes.sh"
EL_HTTP_PORTS+=("${GETH_HTTP_PORTS[@]}")
EL_RPC_PORTS+=("${GETH_RPC_PORTS[@]}")
PROCS_TO_KILL+=("${GETH_BINARY}")
CLEANUP_DIRS+=("${GETH_DATA_DIRS[@]}")
fi
Expand All @@ -449,6 +454,7 @@ if [[ "${RUN_NIMBUS}" == "1" ]]; then

. "./scripts/start_nimbus_el_nodes.sh"
EL_HTTP_PORTS+=("${NIMBUSEL_HTTP_PORTS[@]}")
EL_RPC_PORTS+=("${NIMBUSEL_RPC_PORTS[@]}")
PROCS_TO_KILL+=("${NIMBUS_EL_BINARY}")
CLEANUP_DIRS+=("${NIMBUSEL_DATA_DIRS[@]}")
fi
Expand Down Expand Up @@ -857,7 +863,7 @@ for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do
done
fi

WEB3_ARG="--web3-url=http:https://127.0.0.1:${EL_HTTP_PORTS[${NUM_NODE}]}"
WEB3_ARG="--web3-url=http:https://127.0.0.1:${EL_RPC_PORTS[${NUM_NODE}]}"


${BEACON_NODE_COMMAND} \
Expand All @@ -874,6 +880,7 @@ for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do
--light-client-enable=on \
--light-client-data-serve=on \
--light-client-data-import-mode=only-new \
--jwt-secret=/tmp/jwtsecret \
${EXTRA_ARGS} \
&> "${DATA_DIR}/log${NUM_NODE}.txt" &

Expand Down Expand Up @@ -928,7 +935,7 @@ if [ "$LC_NODES" -ge "1" ]; then
while :; do
CURRENT_FORK_EPOCH="$(
"${CURL_BINARY}" -s "http:https://localhost:${BASE_REST_PORT}/eth/v1/beacon/states/finalized/fork" | \
tee -a curl_result.txt | "${JQ_BINARY}" -r '.data.epoch')"
"${JQ_BINARY}" -r '.data.epoch')"
if [ "${CURRENT_FORK_EPOCH}" -ge "${ALTAIR_FORK_EPOCH}" ]; then
break
fi
Expand Down
2 changes: 1 addition & 1 deletion scripts/nimbus_el_vars.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NIMBUSEL_DISCOVERY="--discovery=V5"
NIMBUSEL_DISCOVERY="--discovery=None"

NIMBUSEL_PORT_OFFSET="${PORT_OFFSET:-100}"
NIMBUSEL_BINARY="${NIMBUSEL_BINARY:-"${HOME}/work/nimbus-eth1/build/nimbus"}"
Expand Down
2 changes: 1 addition & 1 deletion scripts/run-catalyst.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ echo \{\
~/go-ethereum/build/bin/geth --http --ws -http.api "engine" --datadir "${GETHDATADIR}" account import <(echo 45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8)

# Start the node (and press enter once to unlock the account)
~/go-ethereum/build/bin/geth --http --ws --http.api "eth,net,engine" -ws.api "eth,net,engine" --datadir "${GETHDATADIR}" --allow-insecure-unlock --unlock "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" --password "" --nodiscover console
~/go-ethereum/build/bin/geth --http --ws --http.api "eth,net,engine" -ws.api "eth,net,engine" --datadir "${GETHDATADIR}" --allow-insecure-unlock --unlock "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" --password "" --nodiscover --authrpc.jwtsecret /tmp/jwtsecret console
30 changes: 14 additions & 16 deletions scripts/start_geth_nodes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,31 @@ GETH_DATA_DIRS=()

log "Using ${GETH_BINARY}"

for NUM_NODE in $(seq 0 $(( GETH_NUM_NODES - 1 ))); do
GETH_NET_PORT=$(( NUM_NODE * GETH_PORT_OFFSET + GETH_NET_BASE_PORT ))
GETH_HTTP_PORT=$(( NUM_NODE * GETH_PORT_OFFSET + GETH_HTTP_BASE_PORT ))
GETH_WS_PORT=$(( NUM_NODE * GETH_PORT_OFFSET + GETH_WS_BASE_PORT ))
GETH_AUTH_RPC_PORT=$(( NUM_NODE * GETH_PORT_OFFSET + GETH_AUTH_RPC_PORT_BASE ))
log "Starting geth node ${NUM_NODE} on net port ${GETH_NET_PORT} HTTP port ${GETH_HTTP_PORT} WS port ${GETH_WS_PORT}"
GETHDATADIR=$(mktemp -d geth-data-XXX)
for GETH_NUM_NODE in $(seq 0 $(( GETH_NUM_NODES - 1 ))); do
GETH_NET_PORT=$(( GETH_NUM_NODE * GETH_PORT_OFFSET + GETH_NET_BASE_PORT ))
GETH_HTTP_PORT=$(( GETH_NUM_NODE * GETH_PORT_OFFSET + GETH_HTTP_BASE_PORT ))
GETH_WS_PORT=$(( GETH_NUM_NODE * GETH_PORT_OFFSET + GETH_WS_BASE_PORT ))
GETH_AUTH_RPC_PORT=$(( GETH_NUM_NODE * GETH_PORT_OFFSET + GETH_AUTH_RPC_PORT_BASE ))
log "Starting geth node ${GETH_NUM_NODE} on net port ${GETH_NET_PORT} HTTP port ${GETH_HTTP_PORT} WS port ${GETH_WS_PORT}"
GETHDATADIR=$(mktemp -d "${DATA_DIR}"/geth-data-XXX)
GETH_DATA_DIRS+=(${GETHDATADIR})
${GETH_BINARY} --http --ws -http.api "engine" --datadir "${GETHDATADIR}" init "${GENESISJSON}"
#${GETH_BINARY} --http --ws -http.api "engine" --datadir "${GETHDATADIR}" account import <(echo 45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8)
#${GETH_BINARY} --http --ws --http.api "eth,net,engine" -ws.api "eth,net,engine" --datadir "${GETHDATADIR}" --allow-insecure-unlock --unlock "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" --password ${PASSWORDFILE} --nodiscover console
${GETH_BINARY} --http --ws --http.api "eth,net,engine" -ws.api "eth,net,engine" --datadir "${GETHDATADIR}" ${DISCOVER} --port ${GETH_NET_PORT} --http.port ${GETH_HTTP_PORT=} --ws.port ${GETH_WS_PORT} --authrpc.port ${GETH_AUTH_RPC_PORT} &>/dev/null &
${GETH_BINARY} --http --ws --http.corsdomain '*' --http.api "eth,net,engine" -ws.api "eth,net,engine" --datadir "${GETHDATADIR}" ${DISCOVER} --port ${GETH_NET_PORT} --http.port ${GETH_HTTP_PORT} --ws.port ${GETH_WS_PORT} --authrpc.port ${GETH_AUTH_RPC_PORT} --authrpc.jwtsecret /tmp/jwtsecret &> "${DATA_DIR}/geth-log${GETH_NUM_NODE}.txt" &
sleep 5
NODE_ID=$(${GETH_BINARY} attach --datadir "${GETHDATADIR}" --exec admin.nodeInfo.enode)
GETH_ENODES+=(${NODE_ID})
GETH_HTTP_PORTS+=(${GETH_HTTP_PORT})
GETH_NET_PORTS+=(${GETH_NET_PORT})
GETH_WS_PORTS+=(${GETH_WS_PORT})
GETH_RPC_PORTS+=(${GETH_AUTH_RPC_PORT})
GETH_ENODES+=("${NODE_ID}")
GETH_HTTP_PORTS+=("${GETH_HTTP_PORT}")
GETH_NET_PORTS+=("${GETH_NET_PORT}")
GETH_WS_PORTS+=("${GETH_WS_PORT}")
GETH_RPC_PORTS+=("${GETH_AUTH_RPC_PORT}")
done

#Add all nodes as peers
for dir in "${GETH_DATA_DIRS[@]}"
do
for enode in "${GETH_ENODES[@]}"
do
$(${GETH_BINARY} attach --datadir "${dir}" --exec "admin.addPeer(${enode})")
${GETH_BINARY} attach --datadir "${dir}" --exec "admin.addPeer(${enode})"
done
done

Expand Down
5 changes: 3 additions & 2 deletions scripts/start_nimbus_el_nodes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ for NUM_NODE in $(seq 0 $(( NIMBUSEL_NUM_NODES - 1 ))); do
log "Starting nimbus EL node ${NUM_NODE} on net port ${NIMBUSEL_NET_PORT} HTTP port ${NIMBUSEL_HTTP_PORT} WS port ${NIMBUSEL_WS_PORT}"
NIMBUSEL_DATADIR=$(mktemp -d nimbusel-data-XXX)
NIMBUSEL_DATA_DIRS+=("${NIMBUSEL_DATADIR}")
${NIMBUSEL_BINARY} --data-dir="${NIMBUSEL_DATADIR}" --custom-network="${NIMBUSEL_GENESIS}" "${NIMBUSEL_DISCOVERY}" --tcp-port="${NIMBUSEL_NET_PORT}" \
--rpc --rpc-port="${NIMBUSEL_HTTP_PORT}" &>/dev/null &
${NIMBUSEL_BINARY} --data-dir="${NIMBUSEL_DATADIR}" --custom-network="${NIMBUSEL_GENESIS}" "${NIMBUSEL_DISCOVERY}" \
--tcp-port="${NIMBUSEL_NET_PORT}" --engine-api --engine-api-port="${NIMBUSEL_AUTH_RPC_PORT}" \
--rpc --rpc-port="${NIMBUSEL_HTTP_PORT}" &> "${DATA_DIR}/nimbusel_log${NUM_NODE}.txt" &
sleep 5
NODE_ID=$(
"${CURL_BINARY}" -sS -X POST \
Expand Down

0 comments on commit 9d0be3d

Please sign in to comment.