whisper icon indicating copy to clipboard operation
whisper copied to clipboard

shh_getFilterMessages always returns empty array

Open kclowes opened this issue 6 years ago • 5 comments

  • Parity Ethereum version: 2.2.11
  • Operating system: MacOS
  • Installation: homebrew
  • Fully synchronized: yes
  • Network: dev
  • Restarted: no

Parity client running with the following options: parity --config dev -lrpc=trace --whisper

When running the following snippet from web3.py:

from web3.auto import w3 
from web3.shh import Shh 
shh = Shh(w3) 
kp = shh.newKeyPair()
pubkey = shh.getPublicKey(kp)
privkey = shh.getPrivateKey(kp)
flt = shh.newMessageFilter({'topics': ['0x12345678'], 'privateKeyID': kp})
shh.post({ 
             'from': kp,
             'payload': w3.toHex(text="This is a test!"),
             'to': {'public': pubkey}, 
             'topics': ['0x12345678'],
             'priority': 1000, 
             'ttl': 100, 
}) 
received_messages = shh.getMessages(flt.filter_id)

received_messages which calls shh_getFilterMessages under the hood, comes back with an empty result ({"jsonrpc":"2.0","result":[],"id":14}.), even though there should be a message. Any hints would be awesome! Thanks!

kclowes avatar Apr 03 '19 18:04 kclowes

I'm not sure you can receive messages you send yourself, from what I understand of whisper. Whisper builds a filter of messages it's seen before as it runs and ignores them; if that includes the messages it's sent, seeing an empty result would make sense - can you try sending and receiving from different nodes?

jam10o-new avatar Apr 03 '19 19:04 jam10o-new

Thanks for the quick response! Yeah, the same thing happens with:

from web3.auto import w3 
from web3.shh import Shh 
shh = Shh(w3) 
skp = shh.newKeyPair()
spubkey = shh.getPublicKey(kp)
sprivkey = shh.getPrivateKey(kp)
rkp = shh.newKeyPair()
rpubkey = shh.getPublicKey(rkp)
rprivkey = shh.getPrivateKey(rkp)
flt = shh.newMessageFilter({'topics': ['0x12345678'], 'privateKeyID': rkp})
shh.post({ 
             'from': skp,
             'payload': w3.toHex(text="This is a test!"),
             'to': {'public': rpubkey}, 
             'topics': ['0x12345678'],
             'priority': 1000, 
             'ttl': 100, 
}) 
received_messages = shh.getMessages(flt.filter_id)

I don't know if it's helpful or not to add that both of this snippet and the original do return results using geth ¯_(ツ)_/¯

kclowes avatar Apr 03 '19 19:04 kclowes

I'm not sure whether creating a new key pair on the same node will be sufficient but it certainly should be - I'm sure you've noticed but parity-ethereum's whisper implementation is entirely incompatible with geth's 😅

jam10o-new avatar Apr 03 '19 19:04 jam10o-new

Since whisper is not any longer part of parity-ethereum and NOT included in parity 2.7.2, it means that whisper on parity is a dead-end street, right? An easy-to-understand answer from someone here would be highly appreciated. Thank you.

pepihasenfuss avatar Mar 10 '20 08:03 pepihasenfuss

@pepihasenfuss as you can see in the README https://github.com/OpenEthereum/whisper#deprecated, this project is no longer maintained.

ordian avatar Mar 10 '20 09:03 ordian