I have setup a private network for testing Whisper. I cannot make filters based on topics to be of any use, because regardless of how I set them, all messages are received.
I already have found some issues with the documentation]1 so maybe this is more a documentation issue. I have reported it a an issue, but haven't received any answer yet and this is blocking me to continue testing whisper.
System informationGeth version: Geth/v1.7.3-stable-4bb3c89d/linux-amd64/go1.9
posting whisper messages with a topic different from the one used in the message filter should prevent that message to be received
Actual behaviourAl messages post are received regardless of the topics used in the filter and the message.
Steps to reproduce the behaviourThe Following sequence of commands from the geth console reproduce the result:
Welcome to the Geth JavaScript console!
instance: Geth/v1.7.3-stable-4bb3c89d/linux-amd64/go1.9
coinbase: 0xde2326ceead41ddb2a2a421373b619ce4364771c
at block: 0 (Thu, 01 Jan 1970 00:00:00 UTC)
datadir: /var/lib/geth/data
modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 shh:1.0 txpool:1.0 web3:1.0
kp = shh.newKeyPair()
"81ba9ff48a16247ec57a09450bc68171a708fb12217a7bb216919b2536262c1b"
> cb = function(err,messages){console.log(JSON.stringify(err||messages))}
function(err,messages)
> cbe=function(error){console.log(error)}
function(error)
> f = shh.newMessageFilter({topics: ['0x68656c6f'], privateKeyId: kp},cb,cbe)
{
callbacks: [function(err,messages)],
filterId: "2bf504a0c9c075e8b264cc98caca058d6fafca40b546206974e5b43daec0cd84",
formatter: null,
getLogsCallbacks: [],
implementation: {
getLogs: function(),
newFilter: function(),
poll: function(),
uninstallFilter: function()
},
options: {
privateKeyId: "81ba9ff48a16247ec57a09450bc68171a708fb12217a7bb216919b2536262c1b",
topics: ["0x68656c6f"]
},
pollFilters: [],
requestManager: {
polls: {
2bf504a0c9c075e8b264cc98caca058d6fafca40b546206974e5b43daec0cd84: {
data: {...},
id: "2bf504a0c9c075e8b264cc98caca058d6fafca40b546206974e5b43daec0cd84",
callback: function(error, messages),
uninstall: function()
}
},
provider: {
newAccount: function(),
openWallet: function(),
send: function github.com/ethereum/go-ethereum/console.(*bridge).Send-fm(),
sendAsync: function github.com/ethereum/go-ethereum/console.(*bridge).Send-fm(),
sign: function(),
unlockAccount: function()
},
timeout: {},
poll: function(),
reset: function(keepIsSyncing),
send: function(data),
sendAsync: function(data, callback),
sendBatch: function(data, callback),
setProvider: function(p),
startPolling: function(data, pollId, callback, uninstall),
stopPolling: function(pollId)
},
get: function(callback),
stopWatching: function(callback),
watch: function(callback)
}
> pubKey = shh.getPublicKey(kp)
"0x04a0068172ab906410c12bcccfdfa8530239b57885513aee35411196466b544c12559f739efcd1455e24206e35ba2e0aadb0330b684fb76741d64e7ee6280bd45a"
shh.post({ttl: 7, powTarget: 2.01, powTime: 2, payload: '0x68656c6c6f', topic: '0x68656c6f', pubKey: pubKey})
true
> {"hash":"0x5169a2984c15cf2c46a15879e90ad3a7a62112c992860f7efa6b6d491bc670cf","padding":"0xa7be508d8914d8aecec03fbfd7f5713424cc4fe844a3d6bf32ab3381ff19f468b97e1c356f66109c0e176d655ceec09c0bb7bb7599765bfea0df058adb077f165f3dbb9d1701b5ef258bd411d4c00e3e5daeaed458e335e8999f46eef39da1c8f95eaa74a8576b08d678ccf2fa18297260402fcc1a7612fa2fae6f8476687d9cbcbbbf373b7bcc1578acbf996d43a717d463af638907b729c5611118305cc4222ee3f4236f2399d8f447f72abcf0a0f407ff6e5d35c0d2197e88dbb1c044f63c9c62564d34c6f0d23d96bee8e9fdcbc464fdd467ebd6c7d09e0f90469bef2723e8e00ee38bd015d72bba2f75241f088c5e52e1771993af1aff","payload":"0x68656c6c6f","pow":3.0007326007326007,"recipientPublicKey":"0x04a0068172ab906410c12bcccfdfa8530239b57885513aee35411196466b544c12559f739efcd1455e24206e35ba2e0aadb0330b684fb76741d64e7ee6280bd45a","timestamp":1518811000,"topic":"0x68656c6f","ttl":7
If I change the Post topic, message is still received
shh.post({ttl: 7, powTarget: 2.01, powTime: 2, payload: '0x68656c6c6f', topic: '0x20202020', pubKey: pubKey})
true
> {"hash":"0xea7b345e3cfd866fe966a041156ef6ceb58d054dd63db33604b79d4010efc7d5","padding":"0x4d6e3e1a3879f07c74511919b5d3b65918474a426a0a32913a1d3ce724bd24071542fb6d338bc565c6d3969ec45fddb11c0d5163331055605623c8bff376447971bccb5fb7dedee88a4cf54838dbdcbe3fb4ca74629ef04da83f6e75481a43634f0a5aec3e9ee2c375659bcffe56ecb56066f280e7ffc840f290015f4f0d493130cfb964bf2141a1dd3cbaedad66255c7a66d1184b09a206a72339566dab76809ca9507eb9d506a957b05956dcd0a0b39571782b884ef1195499af6f0b9fcbc0f99ca8d0898babe95fbe8fcc62a6f350245a65918e22edac33fcb7cec17b043a0a7b2dc6603de8e2beb71539554801ed2f138adeefe4a2961a","payload":"0x68656c6c6f","pow":6.0014652014652015,"recipientPublicKey":"0x04a0068172ab906410c12bcccfdfa8530239b57885513aee35411196466b544c12559f739efcd1455e24206e35ba2e0aadb0330b684fb76741d64e7ee6280bd45a","timestamp":1518811012,"topic":"0x20202020","ttl":7}
Notice that the topic is received with the message used in the post, therefore It seems like it is not being ignored.
I have tested with both symmetric and asymmetric keys, and also posting from a different node than the one on which I define the filter. In any case, as long as keys match, the message is received.