-
Notifications
You must be signed in to change notification settings - Fork 111
Conversation
c0eff2c
to
588ab17
Compare
https://travis-ci.org/ethersphere/go-ethereum/jobs/443683817#L439 |
swarm/pss/api.go
Outdated
}, | ||
} | ||
if raw { | ||
hndlr.caps |= handlerCapRaw |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wdym?
// - no prox handler on message and partial address matches | ||
// - prox handler on message and we are in prox regardless of partial address match | ||
// store this result so we don't calculate again on every handler | ||
var isProx bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I think you execute a raw handler for a message if there is another handler that allows prox even if that handler does not allow prox.
I think this logic should be different now, instead of isSelf
calls we should just have a call to func getHandlersFor(topic, type) *handler
when the type
enum is
raw
if the message is rawsym
if the message has a symkey hintasym
if there is no hint.
the handlers would be in a map indexed by topic+type serialised.
this would return a list of handlers where the handler would have an address matcher
to be called with address and sym key hint.
func (*handler) match(address, symhint) (payload []byte, handlers []*handlerFunc, forward bool)
this would
- lookup decryption key from hint and open for sym
- it would match on address
- or partial address if allowed
- or proximity if allowed
- or it would decrypt with asym if there was no hint
and return the decrypted payload and the handlers that matched and a bool to indicate if the message needs to be forwarded (only false if full destination address matches)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I think you execute a raw handler for a message if there is another handler that allows prox even if that handler does not allow prox.
It's not clear to mean what you mean here, but the condition in pss.go:380
stops handling of raw message if no raw handlers are registered for the topic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure but it still tries it even though we could know better by then....
f42eca7
to
9edcb1c
Compare
10def86
to
11f1528
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
swarm/pss/pss_test.go
Outdated
// remote address distances from localAddr to try and the expected outcomes if we use prox handler | ||
remoteDistances := []int{ | ||
255, | ||
kad.MinBinSize + 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is very confusing and most likely wrong. How is kad.MinBinSize
relate to proximity order (you call distance)?
This works only becuse you set peerCount := kad.MinBinSize + 2
, kad.MinProxBinSize
happens to be 2 and you fill the table with peers in PO bins staring from 0.
This is way too arcane for a test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to make sure that I have one peer in each bin, two more peers than NNs. The NNs in this test will be in two separate bins.
Are you arguing that the test will break if kad.MinBinSize
would change? I'm not sure how?
I do agree however that the naming in this test makes it confusing. How about I copy the kad.MinBinSize
to a local var, and only use local var names thereafter?
Also, the algo for forwarding needs fixing as per our convo (see my code) |
@zelig I think this was wrong before. Can you evaluate too please? |
a46ac96
to
b13b05c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor things, otherwise LGTM
swarm/network/kademlia.go
Outdated
@@ -430,6 +433,12 @@ func (k *Kademlia) eachAddr(base []byte, o int, f func(*BzzAddr, int, bool) bool | |||
// the nearest neighbour set with cardinality >= MinProxBinSize | |||
// if there is altogether less than MinProxBinSize peers it returns 0 | |||
// caller must hold the lock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this last comment please
swarm/pss/protocol_test.go
Outdated
@@ -129,7 +129,9 @@ func testProtocol(t *testing.T) { | |||
case <-lmsgC: | |||
log.Debug("lnode ok") | |||
case cerr := <-lctx.Done(): | |||
t.Fatalf("test message timed out: %v", cerr) | |||
_ = cerr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reinstate t.Fatal
line
swarm/pss/pss.go
Outdated
return false | ||
} | ||
|
||
minProx := p.Kademlia.NeighbourhoodDepth() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would call this depth
swarm/pss/pss.go
Outdated
} | ||
|
||
minProx := p.Kademlia.NeighbourhoodDepth() | ||
depth, _ := p.Kademlia.Pof(p.Kademlia.BaseAddr(), msg.To, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would call it po
or msgpo
if err != nil { | ||
return err | ||
} | ||
if p.isSelfPossibleRecipient(pssMsg, true) && p.topicHandlerCaps[topic].prox { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worth a comment that this is loopback
45e6069
to
8b7918b
Compare
swarm/pss/pss.go
Outdated
|
||
if minProx <= depth { | ||
if po <= depth { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but now the other way round :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol sorry. thanks for catching it
Submitted upstream ethereum/go-ethereum#18169 |
This is the first in a series of PR providing the following enhancements to PSS:
Send fully addressed messages to neighbourhoods
The possibility of sending a message with full
PssAddress
to a neighbourhood of nodes, by interactive with the Kademlia. The primary use case is chunk syncing, where the chunk will have full address but nodes that have responsibility for storing the chunk should still regard themselves as recipients of it.Mitigate external influence of resource expenditure
If receiving raw messages, currently all raw messages will be passed on to handling code, effectively passing the responsibility of limiting resource expenditure to the handlers. This can be risky, in case of implementations that do not protect against request flooding. Whether to handle raw messages or not should therefore be explicitly set on the handler.
This also pertains to symmetric decryptions, were all registered symmetric keys (for decryption) share the same LRU cache which is tried sequentially on the decrypt. Instead, there should be symkey decrypt caches per topic.
Symkey filter in message type
To reduce resource expenditure in symmetric decryption, an extra field in the message type will be introduced where up to 32 bytes of symmetric key hint can be added. The hint is a hash of the symmetric key, indexed on both sides. The symkey cache must be refactored to be able to take advantage of this hint. A zero-value in this field would indicate public key crypto.
This also clears the way for upgrading whisper support to v6, as one of the changes in whisper v6 is omission of the symkey nonce in the whisper envelope; with this field it's still possible to identify incoming symmetrically encrypted messages, to avoid a forced attempt of asymmetric decryption on every reception.
Part 1
protocols
,handshakes
,pss/client
andnotify
have all been edited to pass tests with the newHandler
struct, but need to be revisited for implementation details. This will follow in a later PRThe PR also replaces the
-v[v]
verbosity flags for tests with--loglevel
flag that sets the loglevel explicitly, and default level to 2 (log.Warn
).