Skip to content

Conversation

@joostjager
Copy link
Contributor

@joostjager joostjager commented Apr 27, 2020

To keep supporting older clients, it is required for the server to know the protocol version that a client adheres to. This PR adds that version as a field to the loop in and out initiation calls.

@joostjager joostjager requested review from bhandras and carlaKC April 27, 2020 13:45
@joostjager joostjager added this to the 0.6.0 milestone Apr 27, 2020
bytes last_hop = 5;

/// The protocol version that the client adheres to.
ProtocolVersion protocol_version = 6;
Copy link
Member

Choose a reason for hiding this comment

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

Question is, should we version all RPC calls? Or just loops?
Should we use server reflection instead? (https://github.com/grpc/grpc-go/tree/master/examples/features/reflection)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you get a version number with server reflection?

What is versioned here is just the protocol version (scripts etc), not the RPC interface. For that, we'd need to have a separate endpoint like GetVersion in lnd.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Going to look into the grpc context, maybe that can carry the version number.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Discussed with @guggero and grpc metadata doesn't seem a great idea. It is all string based (no nice enum) and also proxies may change the keys 😨

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added version to all RPC calls.

Copy link
Member

Choose a reason for hiding this comment

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

Server reflection may be used for protocol discovery, which would be useful for clients to check if their protocol description is compatible with the server protocol description. Afaik context may be used to store a version number (it's similar to http headers) but that also is somewhat hidden (as in not reflected in the proto definitions).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The point is that not every aspect of the protocol (which for example also includes the on-chain htlc bitcoin script), can be observed from the proto signatures.

Using the grpc metadata in the context seems not very attractive (see comment above)

Copy link
Contributor

@carlaKC carlaKC left a comment

Choose a reason for hiding this comment

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

This PR adds that version as a field to the loop in and out initiation calls.

Are we sure we won't need version fields on the RPC endpoints? If it's feasible, I can see some regrets down the line that we didn't just add them all now. It might also be useful to have them for all calls for meta information; perhaps a certain version is always calling for quotes but never looping, might pick up an unreported bug?

Also uncertain of the current enum's meaning (might just be a naming issue, if I have the right idea).

LEGACY = 0;

/// Client reports its supported protocol version.
REPORT_VERSION = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

So this enum will be extended to have additional protocol versions? If that's the case the name REPORT_VERSION and its comment don't make sense to me - makes me think we're going to provide a specific version value somewhere.

Also, how are these protocol versions tracked? By adding an enum to this proto?
Thinking about the case of a non-loop client (if we're accounting for that), how do I know what version I'm supporting?

Copy link
Member

Choose a reason for hiding this comment

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

I can agree with @carlaKC here, the naming is a bit confusing. Perhaps instead of calling it ProtocolVersion we could call itt SwapProtocol (if I understand the purpose correctly), and have better naming for the individual protocol identifiers.

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 think that the confusion is that REPORT_VERSION itself is a feature that a client can support?

The idea is indeed that with every protocol change we do on the server, we add a value to the enum. Then the next client release will start sending that enum value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Loop is all about swaps, so SwapProtocol doesn't add more information than just Protocol in my opinion.

Suggestions for what to rename REPORT_VERSION to?

Copy link
Member

Choose a reason for hiding this comment

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

I think a better question is how will we use REPORT_VERSION? Isn't LEGACY the only version we use now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can also call it MULTI_LOOP_OUT?

Copy link
Member

Choose a reason for hiding this comment

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

That is much better :) I'd be happy with that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

Copy link
Member

@bhandras bhandras left a comment

Choose a reason for hiding this comment

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

LGTM

@joostjager joostjager requested a review from carlaKC April 28, 2020 15:03
Copy link
Contributor

@carlaKC carlaKC left a comment

Choose a reason for hiding this comment

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

Looks good ✅

@joostjager joostjager merged commit b054e84 into lightninglabs:master Apr 28, 2020
@joostjager joostjager deleted the report-version branch May 6, 2020 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants