-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstart_network.py
62 lines (49 loc) · 2.45 KB
/
start_network.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import socket
import subprocess
from subprocess import PIPE
from time import sleep, time
from web3 import Web3
def get_IP():
"""Returns the local IP address.
Credits for this function go to user 'dlm' in
https://stackoverflow.com/questions/166506/finding-local-ip-addresses-using-pythons-stdlib
(Accessed 05/28/2021)
"""
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
s.connect(('<broadcast>', 0))
return s.getsockname()[0]
def start_network(ip):
"""This function starts all nodes and the eth-stats server."""
subprocess.Popen(["PORT=2056 WS_SECRET=asdf npm start"], shell=True,
stdout=PIPE, stderr=PIPE, cwd="./eth-netstats/")
subprocess.Popen(["./geth --datadir ./ethereum \
--gcmode archive \
--networkid 47 --http.api \"txpool,miner,ethash,personal,eth,net,web3\" \
--port 30301 --http --http.corsdomain=\"http://remix.ethereum.org\" \
--rpc --rpcapi \"web3,net,eth,admin,personal\" --rpcaddr " + ip + " \
--rpcport 8545 --rpccorsdomain=\"*\" --http.port 8101 --allow-insecure-unlock \
--nat extip:" + ip + " --ethstats ethereum:asdf@" + ip + ":2056"],
shell=True, stdout=PIPE, stderr=PIPE)
subprocess.Popen(["./geth --datadir ./ethereum2 \
--gcmode archive \
--networkid 47 --http.api \"txpool,miner,ethash,personal,eth,net,web3\" --port 30302 \
--http.port 8102 --nat extip:" + ip + " --ethstats ethereum2:asdf@" + ip + ":2056"],
shell=True, stdout=PIPE, stderr=PIPE)
subprocess.Popen(["./geth --datadir ./ethereum3 \
--gcmode archive \
--networkid 47 --http.api \"txpool,miner,ethash,personal,eth,net,web3\" --port 30303 \
--http.port 8103 --nat extip:" + ip + " --ethstats ethereum3:asdf@" + ip + ":2056"],
shell=True, stdout=PIPE, stderr=PIPE)
subprocess.Popen(["./geth --datadir ./ethereum4 \
--gcmode archive \
--networkid 47 --http.api \"txpool,miner,ethash,personal,eth,net,web3\" --port 30304 \
--http.port 8104 --nat extip:" + ip + " --ethstats ethereum4:asdf@" + ip + ":2056"],
shell=True, stdout=PIPE, stderr=PIPE)
subprocess.Popen(["./geth --datadir ./ethereum5 \
--gcmode archive \
--networkid 47 --http.api \"txpool,miner,ethash,personal,eth,net,web3\" --port 30305 \
--http.port 8105 --nat extip:" + ip + " --ethstats ethereum5:asdf@" + ip + ":2056"],
shell=True, stdout=PIPE, stderr=PIPE)
ip = get_IP()
start_network(ip)