Skip to content
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

Fix mailserver spec #64

Merged
merged 5 commits into from
Nov 25, 2019
Merged

Fix mailserver spec #64

merged 5 commits into from
Nov 25, 2019

Conversation

adambabik
Copy link
Contributor

Closes #55

Copy link
Collaborator

@kdeme kdeme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks clear enough to me to implement. Did mostly some language suggestions (feel free to improve).

However, symmetric key item + the issue of the single versus list of envelopes are still open questions to me.

status-whisper-mailserver-spec.md Outdated Show resolved Hide resolved
status-whisper-mailserver-spec.md Outdated Show resolved Hide resolved
status-whisper-mailserver-spec.md Outdated Show resolved Hide resolved
`Limit`: 4-byte wide unsigned integer limiting the number of returned envelopes
`Cursor`: 32-byte wide array of a cursor returned from the previous request (optional)

The envelope MUST be signed with a symmetric key agreed between the requester and Mailserver.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this symmetric key agreed up on?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just realized that this does not need to be part of the spec and can be arranged out of band (layer higher, etc.)
However, should we then not leave the option open to use either a symmetric or asymmetric key? Such as with the regular posting of messages?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I should make it more generic. It just must be encrypted somehow because each envelope requires that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a feature enhancement request to spec to me, I suggest we note that it has to be agreed out of band in implementer notes in waku spec

For Status app it is hardcoded, iirc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is hardcoded, correct. I will keep it as it is then for now.


### Receiving historic messages

Historic messages MUST be sent to a peer with a packet with a P2P Message code (`0x7f`) followed by a single Whisper envelope OR an array of Whisper envelopes. A peer receiving historic message MUST handle both cases.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit problematic.

  1. I believe it goes against the waku/0 or Whisper/6 spec as there the P2P message code is defined with a single envelope as parameter.
  2. In our nim implementation (DSL) it is not supported to do such thing (1 envelope or list of envelopes) .
    So I would prefer to have waku/0 altered with either always a list of envelopes (can be 1). Or to add a message packet for multiple envelopes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it goes against the waku/0 or Whisper/6 spec as there the P2P message code is defined with a single envelope as parameter.

Correct but in the case when a mailserver returns a lot of messages, sending them one by one adds huge overhead. That's why we batched them.

In our nim implementation (DSL) it is not supported to do such thing (1 envelope or list of envelopes) .
So I would prefer to have waku/0 altered with either always a list of envelopes (can be 1). Or to add a message packet for multiple envelopes.

I would opt for multiple envelopes then. If one wants to send just one, they can do that as one-item array. The problem is that it makes Waku incompatible with Whisper... Can we solve this in the bridge?

Co-Authored-By: kdeme <kim.demey@gmail.com>
status-whisper-mailserver-spec.md Outdated Show resolved Hide resolved
status-whisper-mailserver-spec.md Outdated Show resolved Hide resolved
status-whisper-mailserver-spec.md Outdated Show resolved Hide resolved
Co-Authored-By: Dean Eigenmann <dean.eigenmann@icloud.com>
Copy link
Contributor

@oskarth oskarth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better than before, right level of abstraction now!

Some questions of clarifications on interface


Historic messages MUST be sent to a peer with as packet with a P2P Message code (`0x7f`) followed by a single Whisper envelope OR an array of Whisper envelopes. A peer receiving historic message MUST handle both cases.

In order to accept a P2P Message packet, a node MUST trust a selected Mailserver.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we be more specific about what we mean by "trust"? I suppose this means making certain envelope invariants / checks optional?

E.g. here is roughly the logic in nim-eth as far as I can tell https://github.com/status-im/nim-eth/blob/master/eth/p2p/rlpx_protocols/whisper_protocol.nim#L223-L225

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Generally, a trusted peer in Whisper terminology means it's allowed to send p2p messages.

`Upper`: 4-byte wide unsigned integer (UNIX time in seconds; newest requested envelope's creation time)
`Bloom`: 64-byte wide array of Whisper topics encoded in a bloom filter to filter envelopes
`Limit`: 4-byte wide unsigned integer limiting the number of returned envelopes
`Cursor`: 32-byte wide array of a cursor returned from the previous request (optional)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this returned exactly?

What does it correspond to? I suppose an address of some kind that can be used for that specific mailserver to skip previously fetched messages? Does it send messages 'before' this cursor or after? How does it impact Lower and Upper, i.e. does it cap it to be higher than Lower and lower than Higher according to some logic?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's up to the implementation. Also, it's not possible to query one mailserver and use the obtained cursor to query another one -- I will make it clear. It is so because each mailserver can obtain messages in different order or even may miss some. So it's Whisper property not this spec.

All other questions are up to the implementation due to what I wrote above.

`Limit`: 4-byte wide unsigned integer limiting the number of returned envelopes
`Cursor`: 32-byte wide array of a cursor returned from the previous request (optional)

The envelope MUST be signed with a symmetric key agreed between the requester and Mailserver.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a feature enhancement request to spec to me, I suggest we note that it has to be agreed out of band in implementer notes in waku spec

For Status app it is hardcoded, iirc.


### Receiving historic messages

Historic messages MUST be sent to a peer with as packet with a P2P Message code (`0x7f`) followed by a single Whisper envelope OR an array of Whisper envelopes. A peer receiving historic message MUST handle both cases.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The single or array seems a bit suboptimal to me, ideally this should be just array and then it can even be empty, just like Messages packet.

Seems like an oversight in initial EIP627, perhaps this interface is something we can fix for later versions of waku.

Copy link
Collaborator

@kdeme kdeme Nov 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, agree. That's why I suggested either changing this packet like you say -> array which can be empty. Or adding a new packet id, which does this, to the waku spec.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replied with the same suggestions. Just note that it will be incompatible with EIP-627.

@kdeme
Copy link
Collaborator

kdeme commented Nov 22, 2019

By the way, are any of the additional packet ids (still) used for mailserver functionality?

p2pRequestComplete, p2pSyncRequest, p2pSyncResponse sound related. (https://github.com/status-im/nim-eth/blob/master/eth/p2p/rlpx_protocols/whisper_protocol.nim#L228)

@adambabik
Copy link
Contributor Author

@kdeme p2pSync* are not relevant. They are used to sync between mailservers like when you start a new one but want to get history from another one. I would not worry about this now.

p2pRequestComplete might be actually worth to implement. Otherwise, it's unknown when all messages were sent from a mailserver. Unless we have a better idea for this.

Copy link
Contributor

@oskarth oskarth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@adambabik
Copy link
Contributor Author

@kdeme I describe P2P Request Complete code in 4eb554a.

Copy link
Collaborator

@kdeme kdeme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK for me now, however I think once we move to a Waku version of this spec we should readdress this:
It is incompatible with the original Whisper spec (EIP-627) because it allows only a single envelope, however, an array of envelopes is much more performant. In order to stay compatible with EIP-627, a peer receiving historic message MUST handle both cases.

No need to mention that much then anymore about compatibility with EIP-627.
It can be done in the section which explains the differences between Whisper and Waku somewhere?

@adambabik
Copy link
Contributor Author

@kdeme If we have a section about differences, we can reference it here. But I think we must mention what is incompatible for clarify in the relevant sections. I agree that explanation can be in a different place.

It can be done in the section which explains the differences between Whisper and Waku somewhere?

Waku is speced in a different repo. Here we just want to describe the current state of the protocol.

@kdeme
Copy link
Collaborator

kdeme commented Nov 25, 2019

@adambabik Yeah, for the current state of the protocol I'm perfectly fine with it. As we base ourselves on EIP-627 in those specs / implementations.

Just a reminder for later.

@adambabik adambabik merged commit b8cabfd into master Nov 25, 2019
@adambabik adambabik deleted the fix-mailserver-spec branch November 25, 2019 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix Whisper usage spec wrt mailserver
4 participants