-
Notifications
You must be signed in to change notification settings - Fork 117
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
[2/?] Instant loop out: Add reservations #632
Conversation
e645061
to
843044c
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.
This is great work @sputn1ck. I think future features will benefit from your code structure. I've just left a couple of things that sprung to my eye so far.
843044c
to
fca0849
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.
Some more comments.
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.
Some more comments
a4dc78e
to
76559c6
Compare
94f7293
to
e561c00
Compare
9f6f3ae
to
e9a477e
Compare
bed3fd0
to
b6a3924
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.
Excellent work, I added some comments, most of them are nits. Almost ready!
fsm/fsm.go
Outdated
@@ -117,10 +126,42 @@ type StateMachine struct { | |||
} | |||
|
|||
// NewStateMachine creates a new state machine. | |||
func NewStateMachine(states States) *StateMachine { | |||
func NewStateMachine(states States, | |||
withoutDefaultObserver ...bool) *StateMachine { |
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.
What's the use for the variadic argument? If it is to avoid having an arg sometimes but being able to define it other times, then I'd recommend just keeping it as a normal arg for better readability.
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.
Another cleaner way is to use an option modifier type instead.
fsm/fsm.go
Outdated
var defaultObserver *CachedObserver | ||
|
||
if len(withoutDefaultObserver) == 0 || !withoutDefaultObserver[0] { | ||
defaultObserver = NewCachedObserver(100) |
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.
Can you add a comment why this is useful? Also is 100 just a magic large number or need to be specifically this high?
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.
100 is just a magic large number. do you have a recommendation?
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.
changed it to pass on a single int for the observer size
reservation/manager.go
Outdated
go func() { | ||
for { | ||
select { | ||
case <-ctx.Done(): |
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.
Shouldn't this goroutine (and this whole function) use the m.runCtx
instead?
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 think this would be correct if the passed in ctx
here was m.runCtx
. RegisterReservationNotifications
is called in Run()
.
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.
Shouldn't this goroutine (and this whole function) use the m.runCtx instead?
I don't think so, as we can return if the client cancels the stream. There would be no more channel to send to
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.
Awesome work @sputn1ck, this is looking really good. I've left more code design and style nits this time and also have some clarifying questions.
b6a3924
to
b2d92f1
Compare
b2d92f1
to
039d90f
Compare
ad85206
to
5d3f91b
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.
Great work @sputn1ck!
|
||
// Create the reservation state machine. We need to pass in the runCtx | ||
// of the reservation manager so that the state machine will keep on | ||
// running even if the grpc conte |
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.
nit: incomplete comment
ebb19d5
to
2d95c6c
Compare
2d95c6c
to
9bbf489
Compare
8e543da
to
f2d5f94
Compare
This commit adds the reservation state machine and actions to the reservation package.
cdf68b2
to
eebf8bb
Compare
6fdaaa4
to
19176d4
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.
Re-reviewed due to added test coverage. LGTM 🎉 🎉
This commit adds the reservation manager to the reservation package. This manager manages the lifecycle of reservations.
This commit adds the ReservationServer service to the proto definitions.
19176d4
to
9b178dd
Compare
Prior PR: #631
Skip 1st commit
This PR adds reservation functionality to loop.
Reservations are 2-of-2 musig2 taproot outputs with a single funder. The output contains an expiry path that allows the funder to spend the funds after N blocks.
Reservations can be used a new type of loop out, where the server commits funds to the 2-of-2 output and the loop client can then trustlessly and instantaneously loop out, allow for rapid rebalancing of channels.
The reservation state machine in this PR looks like this:
TODO:
Next PR: #633