Finally get nodes to connect, ish

This commit is contained in:
Oskar Thoren 2019-02-23 02:44:38 -05:00
parent 6a002476d0
commit f88ccf5d2e
8 changed files with 161 additions and 12 deletions

View File

@ -1 +1,2 @@
*.pyc
*.log

View File

@ -36,3 +36,90 @@ cp static-nodes.json ~/.ethereum/testnet/geth/
geth --testnet --rpc --maxpeers=25 --shh --shh.pow=0.002 --rpcport=8501 --datadir=/tmp/bar --port=30001 --ipcpath /tmp/bar.ipc
geth --testnet --rpc --maxpeers=25 --shh --shh.pow=0.002 --rpcport=8501 --datadir=~/.ethereum/node-b --port=30001
## Setup
This assumes:
```
cp static-nodes.json ~/.ethereum/node-a/
cp static-nodes.json ~/.ethereum/node-b/
```
FIXME: toml config?
```
WARN [02-21|03:27:02.567] Found deprecated node list file /tmp/node-b/static-nodes.json, please use the TOML config file instead.
```
TODO: Consider lowering PoW, but am I even connected to each other?
Can manually hack I guess - what is my enode?
ERROR[02-21|03:28:18.982] bad envelope received, peer will be disconnected peer=57c24fba33c13642 err="envelope with low PoW received: PoW=0.001908, hash=[0x44651a153e4b9d6e8080c35fb81c28f9586c842e28d3e15809b2ef01725e0f3d]"
Manual A and B, into static-nodes?
#enode://01acca361b49bdf611a8ce3f39beaac712bdfefa0d552f25fc7c54217a9e678a9233f0b1622d0c489ff022f7a6ad7387203d45edc000edbf066ff246d35d5e1a@127.0.0.1:30000
#enode://421a707a09d9ff08028fd9e47df876bd4cfbd873ce12cfe00702b068acf077518c5c065fb94b61782287695e276973edfa0361c81227d2e7c0570deedfbe7dbb@127.0.0.1:30001
Ok, not working. Trying to add peer but no luck
admin.addPeer("enode://01acca361b49bdf611a8ce3f39beaac712bdfefa0d552f25fc7c54217a9e678a9233f0b1622d0c489ff022f7a6ad7387203d45edc000edbf066ff246d35d5e1a@127.0.0.1:30000")
# IF same node, then what?
geth --rpc --maxpeers=25 --shh --shh.pow=0.002 --rpcport=8501 --datadir=~/.ethereum/node-b --port=30001 attach
Welcome to the Geth JavaScript console!
for (var p=0; p < admin.peers.length; p++) { console.log(admin.peers[p].enode); }
admin.addPeer("enode://531e252ec966b7e83f5538c19bf1cde7381cc7949026a6e499b6e998e695751aadf26d4c98d5a4eabfb7cefd31c3c88d600a775f14ed5781520a88ecd25da3c6@35.225.227.79:30504")
ok, so this works.
Problem: even with detailed logs very little feedback
If I cal lwith al lthis sync node etc no worky
geth --rpc --maxpeers=25 --shh --shh.pow=0.002 --rpcport=8501 --datadir=~/.ethereum/node-b --port=30001 --vmodule eth/*=2,p2p=4,shh=5,whisper=5 &> node-b.log
ANd addpeer
## Gethy
How to start:
```
geth --rpc --maxpeers=25 --shh --shh.pow=0.002 --rpcport=8501 --datadir=~/.ethereum/node-b --port=30001 --vmodule eth/*=2,p2p=4,shh=5,whisper=5 &> node-b.log
```
or use scripts, look in folder.
```
./scripts/start-node-b.sh &> node-b.log &
```
How to attach:
```
geth --rpc --maxpeers=25 --shh --shh.pow=0.002 --rpcport=8501 --datadir=~/.ethereum/node-b --port=30001 attach
```
admin.addPeer("enode://421a707a09d9ff08028fd9e47df876bd4cfbd873ce12cfe00702b068acf077518c5c065fb94b61782287695e276973dfa0361c81227d2e7c0570deedfbe7dbb@127.0.0.1:30001");
admin.addPeer("enode://421a707a09d9ff08028fd9e47df876bd4cfbd873ce12cfe00702b068acf077518c5c065fb94b61782287695e276973edfa0361c81227d2e7c0570deedfbe7dbb@127.0.0.1:30001");
admin.addPeer("enode://e8b7716c2a972a18f3ef31831fe3c2f8f584e59a877d73eca3ac50581ee94a5ec732bdab33db14e260be8093193eb6c777a0980ab341c3bde0256853ddc07bf5@127.0.0.1:30000");
And if I restart node it disconnects previous ones...
Why?
enode://421a707a09d9ff08028fd9e47df876bd4cfbd873ce12cfe00702b068acf077518c5c065fb94b61782287695e276973edfa0361c81227d2e7c0570deedfbe7dbb@127.0.0.1:44984
geth 7053 user 68u IPv6 141618 0t0 TCP localhost:30000->localhost:44984 (ESTABLISHED)
geth 7415 user 63u IPv4 141044 0t0 TCP localhost:44984->localhost:30000 (ESTABLISHED)

View File

@ -14,11 +14,13 @@ SETTINGS = {
}
}
def tick_process(node):
def tick_process(node, whisper_node):
while True:
#print("tick")
# XXX: careful maybe
whisper_node.tick()
node.tick()
time.sleep(1)
time.sleep(0.1)
def main():
@ -31,16 +33,21 @@ def main():
# Init node
whisper_node = networkwhisper.WhisperNodeHelper(keypair)
node = sync.Node(identity_pk, whisper_node, 'burstyMobile', 'batch')
node = sync.Node(identity_pk, whisper_node, 'onlineDesktop', 'interactive')
#where?
#whisper_node.tick()
# XXX: A bit weird? Or very weird
node.nodes = [node]
# XXX: Doesn't make sense, a doesn't have b info
#node.addPeer(friend_pk, b)
# XXX
node.addPeer(friend_pk, friend_pk)
# Clients should decide policy
node.share(friend_pk)
# Start background thread
thread = threading.Thread(target=tick_process, args=[node])
thread = threading.Thread(target=tick_process, args=[node, whisper_node])
thread.daemon = True
thread.start()
@ -57,3 +64,14 @@ main()
# Ok, can send message
# Now share with these other
# And allow b to run as a proc too
# so it is sending but not recving. Why is this?
# Is it resending? 2fce e.g. for b
# Is it actually trying to receive? static peers etc
# Does burstyMobile impact things? fs
# Looking at naive print I DONT see it resending,sync state is updated! what does this mean?
#hm maybe
#ok, it IS resyncing, just abit slow. TICK? ok 100ms now
# what does bursty mobile mean? lets do onlineDesktop

View File

@ -35,15 +35,22 @@ class WhisperNodeHelper():
# XXX: Doesn't belong here
#kId = self.web3.shh.addPrivateKey(keyPair)
pubKey = self.web3.shh.getPublicKey(self.kId)
#print("***PUBKEY", pubKey)
myFilter = self.web3.shh.newMessageFilter({'topic': topic,
print("***KID", self.kId)
print("***PUBKEY", pubKey)
myFilter = self.web3.shh.newMessageFilter({'topic': self.topic,
'privateKeyID': self.kId})
# Purpose of this if we do getMessages?
myFilter.poll_interval = 600;
# XXX: Does this actually do anything?
return myFilter
# XXX: BUG - this isn't ticking! I guess it should?!?!?!?!
# TODO HEREATM
def tick(self):
filterID = self.myFilter.filter_id
#print("*** tick whisper", filterID)
retreived_messages = self.web3.shh.getMessages(filterID)
#print("*** tick whisper retrieved", retreived_messages)
# TODO: Deal with these messages similar to simulation
# receiver.on_receive(sender, msg)
@ -78,7 +85,7 @@ class WhisperNodeHelper():
receiver.on_receive(sender, msg)
#print ""
print("tick", self.time + 1)
#print("tick", self.time + 1)
#print "-----------"
# XXX: This is ugly, why is this ticking nodes?
@ -106,8 +113,11 @@ class WhisperNodeHelper():
# sender id / pubkey not needed for now
# topic assumed to be hardcoded
# HEREATM, not sure if it works or not
# ok it sends, but not being picked up
# static-nodes same?
def send_message(self, sender_id, address_to, msg):
print("*** (whisper-network) send_message", address_to)
print("*** (whisper-network) send_message to", address_to)
# XXX: Is this what we want to do?
payload = msg.SerializeToString()
print("*** (whisper-network) send_message payload", payload)

View File

@ -3,4 +3,14 @@
# Should probably be a subprocess in python and print to some logger
# Or Docker compose or whatever.
geth --testnet --syncmode=light --rpc --maxpeers=25 --shh --shh.pow=0.002 --rpcport=8500 --datadir=/tmp/node-a --port=30000
echo "[Starting node-a...]"
echo "[Copying static-nodes...]"
#cp static-nodes.json /tmp/node-a/
cp static-nodes.json ~/.ethereum/node-a/
#geth --testnet --syncmode=light --rpc --maxpeers=25 --shh --shh.pow=0.002 --rpcport=8500 --datadir=~/ethereum/node-a --port=30000
#geth --testnet --syncmode=light --rpc --maxpeers=25 --shh --shh.pow=0.002 --rpcport=8501 --datadir=~/.ethereum/node-b --port=30001 --verbosity=4
echo "[geth starting at port 30000, see node-a.log for logs.]"
geth --rpc --maxpeers=25 --shh --shh.pow=0.002 --rpcport=8500 --datadir=~/.ethereum/node-a --port=30000 --vmodule eth/*=2,p2p=4,shh=5,whisper=5 #&> node-a.log

View File

@ -3,4 +3,13 @@
# Should probably be a subprocess in python and print to some logger
# Or Docker compose or whatever.
geth --testnet --syncmode=light --rpc --maxpeers=25 --shh --shh.pow=0.002 --rpcport=8501 --datadir=/tmp/node-b --port=30001
#cp static-nodes.json /tmp/node-b/
echo "[Starting node-b...]"
echo "[Copying static-nodes...]"
cp static-nodes.json ~/.ethereum/node-b/
#geth --testnet --syncmode=light --rpc --maxpeers=25 --shh --shh.pow=0.002 --rpcport=8501 --datadir=~/.ethereum/node-b --port=30001 --verbosity=4
echo "[geth starting at port 30001, see node-b.log for logs.]"
geth --rpc --maxpeers=25 --shh --shh.pow=0.002 --rpcport=8501 --datadir=~/.ethereum/node-b --port=30001 --vmodule eth/*=2,p2p=4,shh=5,whisper=5 #&> node-b.log

View File

@ -10,5 +10,10 @@
"enode://8a64b3c349a2e0ef4a32ea49609ed6eb3364be1110253c20adc17a3cebbc39a219e5d3e13b151c0eee5d8e0f9a8ba2cd026014e67b41a4ab7d1d5dd67ca27427@206.189.243.168:30504",
"enode://7de99e4cb1b3523bd26ca212369540646607c721ad4f3e5c821ed9148150ce6ce2e72631723002210fac1fd52dfa8bbdf3555e05379af79515e1179da37cc3db@35.188.19.210:30504",
"enode://015e22f6cd2b44c8a51bd7a23555e271e0759c7d7f52432719665a74966f2da456d28e154e836bee6092b4d686fe67e331655586c57b718be3997c1629d24167@35.226.21.19:30504",
"enode://531e252ec966b7e83f5538c19bf1cde7381cc7949026a6e499b6e998e695751aadf26d4c98d5a4eabfb7cefd31c3c88d600a775f14ed5781520a88ecd25da3c6@35.225.227.79:30504"
"enode://531e252ec966b7e83f5538c19bf1cde7381cc7949026a6e499b6e998e695751aadf26d4c98d5a4eabfb7cefd31c3c88d600a775f14ed5781520a88ecd25da3c6@35.225.227.79:30504",
"enode://01acca361b49bdf611a8ce3f39beaac712bdfefa0d552f25fc7c54217a9e678a9233f0b1622d0c489ff022f7a6ad7387203d45edc000edbf066ff246d35d5e1a@127.0.0.1:30000",
"enode://421a707a09d9ff08028fd9e47df876bd4cfbd873ce12cfe00702b068acf077518c5c065fb94b61782287695e276973edfa0361c81227d2e7c0570deedfbe7dbb@127.0.0.1:30001"
]

View File

@ -177,6 +177,8 @@ class Node():
flags['send_time'] <= self.time):
# TODO: Extend to slurp up all, need index peer->message
offer_rec = new_offer_record([message_id])
# HERE we send
# XXX: peer_id, should be pbukey
self.network.send_message(self.name, peer_id, offer_rec)
send_count = self.sync_state[message_id][peer_id]["send_count"] + 1
self.sync_state[message_id][peer_id]["send_count"] = send_count
@ -201,6 +203,7 @@ class Node():
self.network.send_message(self.name, peer_id, message)
# XXX: Why would node know about peer and not just name?
# TODO: Refactor this to illustrate that it is just a set of pubkeys
def addPeer(self, peer_id, peer):
self.peers[peer_id] = peer
@ -235,8 +238,14 @@ class Node():
# Ensure added for each peer
# If we add peer at different time, ensure state init
# TODO: Only share with certain peers, e.g. clientPolicy
# XXX here we go, probably
#print("**SHARE1 SHDNOTBEEMPTY", self.peers)
# TODO: Problem - this shouldn't be empty
# Where does this come from?
for peer in self.peers.keys():
if peer in self.sharing[self.group_id]:
print("**SHARE2", peer)
# ok, then what?
self.sync_state[message_id][peer] = {
"hold_flag": 0,
"ack_flag": 0,