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

[Rendezvous] Draft proof-of-work requirement #334

Closed
wants to merge 4 commits into from

Conversation

thomaseizinger
Copy link
Contributor

This is a draft for the proof of work requirement that is to be defined in the rendezvous protocol.

I've considered a number of designs and ended up with what is presented here. I am not sure how much people will like the additional messages but it solves an important problem: The PoW must be unique to a single registration and the best way to achieve that IMO is for the rendezvous point to hand out a challenge to the client. Given that REGISTER is sent by the client, there isn't really any opportunity before the register response to send back a challenge which is why I opted to introduce a dedicated status code that requests proof of work from the client.

The main consequence of this is that it allows rendezvous points to not require proof of work for the first few registrations for example or whilst they are under low load. I am not sure we need this flexibility but it is there with the current design.

If however we want proof of work with every registration anyway, then the additional message is a bit of a waste and it would be ideal if the client could just include the proof of work with the original REGISTER message. Unfortunately, I could come up with a way of making the PoW unique to this registration. ttl is a relative value and therefore, a PoW that is calculated once could be reused over and over again at a later point in time.

rendezvous/README.md Outdated Show resolved Hide resolved
Once the difficulty requirement is met, a rendezvous point will respond with a
status code of `OK`.

To vary the difficulty, a client can manipulate the `nonce` field.

Choose a reason for hiding this comment

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

Wouldn't the client satisfy the difficulty set by the rendezvous point? The client would vary or manipulate the nonce to produce a hash that satisfies the difficulty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the current proposal, the rendezvous point never specifies a difficulty. Maybe it should but that is another field with need to include the message :)

It might be worth it because then the client doesn't need to "trial and error" in getting the difficulty right.

On the other hand, it doesn't really reduce complexity because we still need to cover the error case where a client ignores that field and sends a hash that doesn't satisfy the difficulty. Hence, the only benefit would be in less round-trips and less hashing on the client which sounds like a good idea.

The client would vary or manipulate the nonce to produce a hash that satisfies the difficulty?

Yep, that is exactly what the spec says, maybe in a sort of contrived way: The nonce is the only field that can be varied by the client to produce a different hash.

@@ -206,6 +254,8 @@ message Message {
E_INVALID_SIGNED_PEER_RECORD = 101;
E_INVALID_TTL = 102;
E_INVALID_COOKIE = 103;
E_POW_REQUIRED = 104;
E_DIFFICULTY_TOO_LOW = 105;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thinking of dropping this one because it is essentially the same message as E_POW_REQUIRED.

Comment on lines +232 to +234
It is worth noting that the `target_difficulty` can change between the initial `E_POW_REQUIRED`
and submitting the PoW. Henceforth, a client must be prepared to receive a `E_DIFFICULTY_TOO_LOW`
message even if they adhered to the previously sent `target_difficulty`.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thinking that this is actually quite annoying and there isn't really a reason for the server to do this. Once they've requested a specific PoW, they SHOULD accept it if the client provides a legitimate PoW.

- The contents of `challenge`
- The `ns` field
- The `signedPeerRecord` field
- The `PeerId` of the rendezvous point we are registering with
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Given the addition of challenge, I am considering dropping this because PoW hashes are now unique to the rendezvous point already.

message ProofOfWork {
optional bytes hash = 1;
optional int64 nonce = 2;
}

optional MessageType type = 1;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needs to be extended with PROOF_OF_WORK variant.

@mxinden
Copy link
Member

mxinden commented Jun 21, 2021

Pinging author and interest group. Does one of you want to take a look at this proposal? Also see #337 for a general discussion on whether to introduce proof of work to the Rendezvous protocol.

@vyzo, @daviddias, @whyrusleeping, @Stebalien, @jacobheun, @yusefnapora, @vasco-santos

@vyzo
Copy link
Contributor

vyzo commented Jun 21, 2021 via email

@thomaseizinger
Copy link
Contributor Author

thomaseizinger commented Jun 22, 2021

we have had on and off discussions about PoW and we are not convinced its the right thing to do. I think its much better to have many rendezvous points and use verified randomness in picking the one to use.

Right, thanks for clarifying! I'll close this then and send another PR that incorporates this knowledge into the spec.

thomaseizinger added a commit to thomaseizinger/specs that referenced this pull request Jun 29, 2021
thomaseizinger added a commit to thomaseizinger/specs that referenced this pull request Jun 29, 2021
@thomaseizinger
Copy link
Contributor Author

we have had on and off discussions about PoW and we are not convinced its the right thing to do. I think its much better to have many rendezvous points and use verified randomness in picking the one to use.

Right, thanks for clarifying! I'll close this then and send another PR that incorporates this knowledge into the spec.

Opened a follow-up PR: #342.

mxinden pushed a commit that referenced this pull request Jul 11, 2021
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.

None yet

4 participants