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

Whisper: Posted messages won't filtered on the other nodes #17545

Open
avatar-lavventura opened this Issue Aug 29, 2018 · 11 comments

Comments

Projects
None yet
3 participants
@avatar-lavventura

avatar-lavventura commented Aug 29, 2018

geth version: 1.8.15-unstable
Python: 3.7.0
OS: linux

The way I run geth:

geth --syncmode fast --cache=1024 --shh --datadir $DATADIR/private --rpcaddr 127.0.0.1 --rpc --rpcport 8545 --rpccorsdomain="*" --networkid 12345 --rpcapi admin,eth,net,web3,debug,personal,shh


I have followed the linked documentations that given on this issue (#17120 (comment)) by @gballet . I have lost on the documentations and could not able to send a single message from one node to another (1-N signalling messages). If there would be an simple example about it would be very helpful.


This is as far as I came, please also see (https://ethereum.stackexchange.com/questions/52218/how-to-send-1-n-signalling-or-broadcast-messages-on-whisper).

On this approach I observe that each node can only sends message to itself and other nodes don't filter/see those messages. For example, when node-1 sends a message to the network; it won't show up on the node-2 such that node-2's web3.shh.info{memory} remains 0, where I assume that it never catches the message.

On node-1's geth-client:

generatedSymKey=shh.generateSymKeyFromPassword("hello");    
symKey=shh.getSymKey(generatedSymKey)    
symKeyID=shh.addSymKey(symKey) //ex: "d5212e736703afbb21246e8acd192e4345ea910398544d765ed6b49f0ec524b5"
filter = web3.shh.newMessageFilter(
        {symKeyID: symKeyID, topic: '0x07678231'}, 
        function(err, res) {console.log(web3.toUtf8(res.payload))});

On node-2's geth-client:

generatedSymKey=shh.generateSymKeyFromPassword("hello")    
symKey=shh.getSymKey(generatedSymKey)    
symKeyID=shh.addSymKey(symKey) //ex: "c4c4cecf6ad9499c2386b8ce6416f44684e042e491726b38315646c0b4afadc6"
filter = web3.shh.newMessageFilter(
        {symKeyID: symKeyID, topic: '0x07678231'}, 
        function(err, res) {console.log(web3.toUtf8(res.payload))});

Then, node-1 sends message to the network, where only node-1 receives it but node-2 does not.

Following code is run on node-1's geth-client:

node-1's symKeyID is given:

web3.shh.post({
  symKeyID: 'd5212e736703afbb21246e8acd192e4345ea910398544d765ed6b49f0ec524b5', //symKeyID of the node-1
  ttl: 10,
  topic: '0x07678231',
  powTarget: 2.01,
  powTime: 2,
  payload: web3.fromAscii("Hello there!")
  });

[Q] How could I able to make node-2 to filter node-1's messages?

Also asked at ethereum.stackexchange but I couldn't reach anyone.

@avatar-lavventura avatar-lavventura changed the title from Whisper: Posted messages won't show up on other nodes to Whisper: Posted messages won't show up on the other nodes Aug 29, 2018

@avatar-lavventura avatar-lavventura changed the title from Whisper: Posted messages won't show up on the other nodes to Whisper: Posted messages won't filtered on the other nodes Aug 29, 2018

@demmojo

This comment has been minimized.

demmojo commented Sep 7, 2018

Hello @avatar-lavventura, I have followed the instructions that you gave above and I am able to see the messages on both nodes. Could you please check again? Just in case, please check that the nodes are peers using 'net.peerCount' which should give a count of 1 if there are no other nodes in the network.

My geth version is: 1.8.15-stable-89451f7c
Python: 2.7.15rc1
OS: Linux

@avatar-lavventura

This comment has been minimized.

avatar-lavventura commented Sep 7, 2018

Ah, I am not sure the reason. I have a small private network. I have delete the chain-data of both nodes and rsync them from 0th block. I verify that both nodes have net.peerCount that is minimum 1 on both nodes and now it works.

Sorry for asking already working example.

@avatar-lavventura

This comment has been minimized.

avatar-lavventura commented Sep 22, 2018

@danmelton : It worked once 15 days ago but when I tried again it does not work anymore. Honestly I don't now the reason behind it :( Same problem also occurred on another user please see #17043 (comment)

I verify that both nodes are connected to the network. net.peerCount returns 3 on both nodes.

=> Currently, I am able to send/receive from the same node, but not from two different ones.

On the reciever shh.info.memory remains 0 when sender node posts a message.

For both machines:
Geth version:1.8.15-unstable
OS: Linux

@gballet

This comment has been minimized.

Contributor

gballet commented Oct 10, 2018

So moving the discussion back here for future cases, you have three nodes:

The bootnode is started with:

bootnode -nodekey bootnode.key -verbosity 9 -addr :300

The first node is started with:

geth --shh --port 3000 --datadir $DATADIR/private --rpcaddr 127.0.0.1 --rpc --rpcport 8545 --rpccorsdomain="*" --networkid 23422 --rpcapi admin,eth,net,web3,debug,personal,shh --nodiscover

And the second node is started with:

geth --bootnodes enode://44d77989e8097b672ac712e516d36bf27b3420e945d3538ca67fcfb16ce579a1f95c0f0c9c64947607727c568f9591163fd0cd4bac25fda67284ff7351dc43ac@[ip redacted]:300 --syncmode fast --cache=1024 --shh --datadir $DATADIR/private --rpcaddr 127.0.0.1 --rpc --rpcport 8545 --rpccorsdomain="*" --networkid 23422 --rpcapi admin,eth,net,web3,debug,personal,shh

And the issue is that, in spite of manually adding peers, you can't get messages from node 1 to node 2.

Do you use web3.js over the RPC api, or the console interface?

@avatar-lavventura

This comment has been minimized.

avatar-lavventura commented Oct 10, 2018

I have used Web3.js console interface (please see) and also Web3'py (please see). In both cases I cannot get message from node-1 to node-2, please note that node-1 and node-2 located on different machines.

@gballet

This comment has been minimized.

Contributor

gballet commented Oct 10, 2018

Alright, so I tested a similar setup to check if the issue was with the peer management system:

I have 5 machines:

  • A boot node (b) started with: b$ bootnode -nodekey bootnode.key -addr :30303
  • Two machines (m1 & m2) with geth running, started as such (mX stands for either m1 or m2:
mX$ geth --datadir=/datadrive --bootnodes b_enode --shh console
  • Two request machines (r1 & r2) running wnode and started as: rX$ wnode -test -boot mX_enode

Where b_enode is the enode of b, m1_enode is the enode of m1 and so on...

  1. r1 and r2 connect to m1 and m2 respectively. If I send a message from r1, r2 doesn't receive it. That's expected, because bootnode doesn't understand Whisper.

  2. From the console of m2 I manually add m1 with addPeer:

admin.addPeer("m1_enode")
  1. From r1, I send a message, and r2 receives it.

So messages do get forwarded from one node to the next. I assume the issue is either in your RPC call or in your own setup.

@avatar-lavventura

This comment has been minimized.

avatar-lavventura commented Oct 10, 2018

=> Does all machines and request machine located on different node?
=> Can both machines (m1 and m2) send whisper message to each other?

@gballet

This comment has been minimized.

Contributor

gballet commented Oct 11, 2018

yes, because otherwise r1 and r2 could not;

@avatar-lavventura

This comment has been minimized.

avatar-lavventura commented Oct 11, 2018

On my case, I have a proof-of-authority private Ethereum Network, which has 3 signer nodes.

I have pretty similar setup. Each machine connects network as follows:

geth --syncmode fast --cache=1024 --shh --datadir $DATADIR/private --rpcaddr 127.0.0.1 --rpc --rpcport 8545 --rpccorsdomain="*" --networkid 23422 --rpcapi admin,eth,net,web3,debug,personal,shh

Later, each node adds all three signer nodes's enodeID manually like you did. All machines are synced and have peer count 3, which is all the signer nodes.

=> But they cannot send any whisper message to any signer nodes or any other connected machine on the network.

@gballet

This comment has been minimized.

Contributor

gballet commented Oct 17, 2018

You should start with what I did, then move step by step to your own configuration to find out at which step the problem occurs, then paste the startup command of every machine for the last step it worked and the first step it didn't.

I spend a lot of time - more time than I have to be precise - just trying to guess what it is that you are doing and you have to make a clarity effort if you want this to go anywhere.

@avatar-lavventura

This comment has been minimized.

avatar-lavventura commented Oct 17, 2018

I am sorry to take your time and please note that thank you for your help. I really do not know why it was not working before but it works on my end now.

Please see my problem more in detail. I have tried little bit different way than you did.


Case: There is no node in the network started as bootnode. But I have manually added static nodes using admin.addPeer().

There are three main nodes, their enode is shared publicly where any new coming peers connected to all those three using admin.addPeer("mX_enode"). mX stands for either m1 or m2 or m3. Also all those 3 nodes are connected to each other using admin.addPeer("mX_enode") as well. I have added few nodes which connects to all those 3 nodes, that makes network more stable.

All those three nodes in the network uses following geth line, and newly connected nodes uses same line without --nodiscover flag:

geth --syncmode fast --cache=1024 --shh --datadir $DATADIR/private --rpcaddr 127.0.0.1 --rpc --rpcport 8545 --rpccorsdomain="*" --networkid 12345 --rpcapi eth,net,web3,personal,shh --nodiscover

Please see the image where all nodes are connected to each other.

screen shot 2018-10-17 at 12 54 15

Later I pick a sender and receiver node, where both admin.peers returns other node's enode so I verify that selected sender and receiver node is connected to each other on the network.

=> Receiver and sender node runs following code on its geth console:

generatedSymKey=shh.generateSymKeyFromPassword("hello");    
symKey=shh.getSymKey(generatedSymKey)    
symKeyID=shh.addSymKey(symKey)
filter = web3.shh.newMessageFilter(
        {symKeyID: symKeyID, topic: '0x07678231'}, 
        function(err, res) {console.log(web3.toUtf8(res.payload))});

I have stored sender and receiver's symKeyID where I will use it to post message. Sender's returned symKeyID is 321f3531fad3de1dd8344da26cba1a074ee3689acb796ecb8e5bdf8507b1a0ef . Receiver's returned symKeyID is ed30b966e40cec9088fb6054c1823d3ff36941aaa002ebd2eea9d5a6efd1a9fe :

=> Than sender node copy paste its symKeyID into following code piece to post its message

web3.shh.post({
  symKeyID: '321f3531fad3de1dd8344da26cba1a074ee3689acb796ecb8e5bdf8507b1a0ef', //symKeyID of the sender
  ttl: 10,
  topic: '0x07678231',
  powTarget: 2.01,
  powTime: 2,
  payload: web3.fromAscii("Hello there!")
  });

=> Receiver also do the same. Receiver copy paste its symKeyID into same code piece to post its message.

web3.shh.post({
  symKeyID: 'ed30b966e40cec9088fb6054c1823d3ff36941aaa002ebd2eea9d5a6efd1a9fe', //symKeyID of the receiver
  ttl: 10,
  topic: '0x07678231',
  powTarget: 2.01,
  powTime: 2,
  payload: web3.fromAscii("Hello there!")
  });

And I can see the sent message on the sender and receiver node's geth console.


I observe that:

In order to user Whisper protocol, where are not required to use any bootnode. Later I have tried running receiver and sender node without --nodiscover and still they were able to send and receive messages between each other.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment