Restore the address file feature (and use it for synchronization in local sim)
This commit is contained in:
parent
14cffdea99
commit
46a3009c63
|
@ -257,6 +257,9 @@ proc connectToNetwork(node: BeaconNode) {.async.} =
|
|||
|
||||
await node.network.connectToNetwork(node.bootstrapEnrs)
|
||||
|
||||
let addressFile = node.config.dataDir / "beacon_node.address"
|
||||
writeFile(addressFile, node.network.announcedENR.toURI)
|
||||
|
||||
template findIt(s: openarray, predicate: untyped): int =
|
||||
var res = -1
|
||||
for i, it {.inject.} in s:
|
||||
|
|
|
@ -909,11 +909,15 @@ proc getPersistenBootstrapAddr*(conf: BeaconNodeConf,
|
|||
ip: IpAddress, port: Port): enr.Record =
|
||||
let
|
||||
pair = getPersistentNetKeys(conf)
|
||||
enode = initENode(pair.pubkey.skkey, Address(ip: ip, udpPort: port))
|
||||
enodeAddress = Address(ip: ip, udpPort: port)
|
||||
|
||||
return enr.Record.init(1'u64, # sequence number
|
||||
pair.seckey.asEthKey,
|
||||
enode.address)
|
||||
enodeAddress)
|
||||
|
||||
proc announcedENR*(node: Eth2Node): enr.Record =
|
||||
doAssert node.discovery != nil, "The Eth2Node must be initialized"
|
||||
node.discovery.localNode.record
|
||||
|
||||
proc shortForm*(id: KeyPair): string =
|
||||
$PeerID.init(id.pubkey)
|
||||
|
|
|
@ -73,8 +73,8 @@ fi
|
|||
rm -f beacon_node.log
|
||||
|
||||
# Delete any leftover address files from a previous session
|
||||
if [ -f "${MASTER_NODE_PID_FILE}" ]; then
|
||||
rm "${MASTER_NODE_PID_FILE}"
|
||||
if [ -f "${MASTER_NODE_ADDRESS_FILE}" ]; then
|
||||
rm "${MASTER_NODE_ADDRESS_FILE}"
|
||||
fi
|
||||
|
||||
# to allow overriding the program names
|
||||
|
@ -134,7 +134,7 @@ fi
|
|||
for i in $(seq $MASTER_NODE -1 $TOTAL_USER_NODES); do
|
||||
if [[ "$i" != "$MASTER_NODE" && "$USE_MULTITAIL" == "no" ]]; then
|
||||
# Wait for the master node to write out its address file
|
||||
while [ ! -f "${MASTER_NODE_PID_FILE}" ]; do
|
||||
while [ ! -f "${MASTER_NODE_ADDRESS_FILE}" ]; do
|
||||
sleep 0.1
|
||||
done
|
||||
fi
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Read in variables
|
||||
set -a
|
||||
# shellcheck source=/dev/null
|
||||
source "$(dirname "$0")/vars.sh"
|
||||
|
||||
cd $(dirname "$0")
|
||||
rm -rf data
|
||||
|
||||
tmux new-session -s 'beacon_node' -d
|
||||
|
||||
# maybe these should be moved to a user config file
|
||||
tmux set-option -g history-limit 999999
|
||||
tmux set -g mouse on
|
||||
|
||||
tmux send-keys -t 0 './start.sh' Enter
|
||||
tmux new-window -n "demo_node" "./wait_master_node.sh && ./run_node.sh 0"
|
||||
|
||||
tmux attach-session -d
|
||||
|
|
@ -32,7 +32,7 @@ SNAPSHOT_FILE="${SIMULATION_DIR}/state_snapshot.ssz"
|
|||
NETWORK_BOOTSTRAP_FILE="${SIMULATION_DIR}/bootstrap_nodes.txt"
|
||||
BEACON_NODE_BIN="${SIMULATION_DIR}/beacon_node"
|
||||
DEPLOY_DEPOSIT_CONTRACT_BIN="${SIMULATION_DIR}/deploy_deposit_contract"
|
||||
MASTER_NODE_PID_FILE="${SIMULATION_DIR}/node-${MASTER_NODE}/beacon_node.pid"
|
||||
MASTER_NODE_ADDRESS_FILE="${SIMULATION_DIR}/node-${MASTER_NODE}/beacon_node.address"
|
||||
|
||||
BASE_P2P_PORT=30000
|
||||
BASE_RPC_PORT=7000
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ ! -f "${MASTER_NODE_PID_FILE}" ]; then
|
||||
echo Waiting for master node...
|
||||
while [ ! -f "${MASTER_NODE_PID_FILE}" ]; do
|
||||
sleep 0.1
|
||||
done
|
||||
fi
|
||||
|
Loading…
Reference in New Issue