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

wtpolicy: migrate to using wtpolicy.Policy + blob bitvector flags #2439

Merged
merged 7 commits into from Jan 16, 2019

Conversation

Projects
None yet
2 participants
@cfromknecht
Copy link
Collaborator

cfromknecht commented Jan 8, 2019

This PR refactors the internal handling of session parameters within the existing watchtower packages in preparation for the watchtower client integration. First, we introduce a blob.Type bitvector, composed of blob.Flags. Blob types are meant to replace the uint16 versioning scheme, and are used to signal what features the client is requesting from the tower.

Two flags are introduced: FlagReward and FlagCommitOutputs:

  • FlagReward is used to indicate if the tower will be getting a portion of the breached balance. Otherwise, the tower will sweep all funds to the client.
  • FlagCommitOutputs instructs the tower that the payload is the fixed-size, v0 blob format. This is added as a flag so that it could, in theory, be turned off and replaced with a different encoding.

Finally, we consolidate our negotiated session parameters into a new wtpolicy.Policy struct. This struct is then threaded through the existing watchtower wire/server/lookout code, as it is already used natively in the client to follow. The server will also now reject blob types for which it doesn't understand, to ensure we don't accept sessions with clients that require a different set of features.

The final commit is added to improve coverage on the JusticeKit's construction of witness scripts and stacks. These are tested indirectly in the lookout package, but now they are tested explicitly in this package.

@cfromknecht cfromknecht force-pushed the cfromknecht:wtpolicy-blob-type branch 3 times, most recently from 291852e to 9b946f9 Jan 10, 2019

watchtower/blob/type: introduces blob type flags
Adds flags for reward outputs and commitment outputs.
The fixed-size encoding for commitment outputs is
treated as a flag, so that the blob format can be
modified, extended, or replaced in future iterations.

@cfromknecht cfromknecht force-pushed the cfromknecht:wtpolicy-blob-type branch from 9b946f9 to 0567f43 Jan 10, 2019

cfromknecht added some commits Jan 10, 2019

watchtower/multi: switch over to wtpolicy
migrate to using wtpolicy.Policy in wtwire messages and wtserver

@cfromknecht cfromknecht force-pushed the cfromknecht:wtpolicy-blob-type branch from 0567f43 to f66e713 Jan 11, 2019

@Roasbeef
Copy link
Member

Roasbeef left a comment

Set of changes looks mostly good to me. Only thing I noticed is that some of the tests look a bit off. It may be a mis-understanding on my end though.

Show resolved Hide resolved watchtower/wtpolicy/policy.go
Show resolved Hide resolved watchtower/blob/justice_kit_test.go
Show resolved Hide resolved watchtower/blob/justice_kit_test.go
Show resolved Hide resolved watchtower/blob/justice_kit_test.go
Show resolved Hide resolved watchtower/blob/justice_kit_test.go
@Roasbeef
Copy link
Member

Roasbeef left a comment

LGTM 💡

Left some additional comments, not blocking, but more an attempt to unify the language that's used within the codebase w.r.t new segwit output scripts.

Show resolved Hide resolved watchtower/blob/justice_kit_test.go
Show resolved Hide resolved watchtower/blob/justice_kit_test.go
Show resolved Hide resolved watchtower/blob/justice_kit_test.go

@Roasbeef Roasbeef merged commit 53a181c into lightningnetwork:master Jan 16, 2019

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.1%) to 56.385%
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment