-
Notifications
You must be signed in to change notification settings - Fork 118
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
[4/?] Instant loop out: Add instant loop outs #651
Conversation
958c349
to
7e8962a
Compare
7e8962a
to
d3d2197
Compare
c6352eb
to
18a50e2
Compare
8424734
to
4a36985
Compare
90fa073
to
a8c2402
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.
Once again nice work @sputn1ck. I've done a first pass and flagged what I noted. I will do a test run next and check the UX.
8796363
to
6c8a4c3
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.
Looks ripe! I think the main issue remaining is fixing the case when the htlc is going on chain but for some reason the daemon restarts before the sweep also is on-chain. Other than that mosly nits! 🎉 🎉
instantout/reservation/actions.go
Outdated
f.Debugf("Reservation expired") | ||
err := f.SendEvent(OnTimedOut, nil) | ||
if err != nil { | ||
f.Errorf("Error sending event:"+ |
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: could extracted into a member function for handling event sending errors.
instantout/manager.go
Outdated
runCtx, cancel := context.WithCancel(ctx) | ||
defer cancel() | ||
|
||
i.Lock() |
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.
Why do we need to lock here?
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 don't think we need to
instantout/manager.go
Outdated
i.Unlock() | ||
return nil, err | ||
} | ||
i.Unlock() |
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 we also want to add the new instantOut
to the activeInstantOuts
.
instantout/manager.go
Outdated
i.Lock() | ||
defer i.Unlock() | ||
|
||
reservation, ok := i.activeInstantOuts[swapHash] |
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.
Should we clean out the finished ones here?
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.
good idea!
6c8a4c3
to
4f66d6f
Compare
4f66d6f
to
a2c18ff
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.
Amazing work @sputn1ck, this looks very close. I found some minor issues while testing the instant out flow which I communicated offline.
There are also some minor issues mentioned in my latest review, including some code and format nits. This is as good as done 🚀
test/lnd_services_mock.go
Outdated
for _, listener := range s.blockHeightListeners { | ||
lis := listener | ||
go func() { | ||
lis <- height |
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.
don't we need the timeout case here?
// byteSliceToReservationIds converts a byte slice to a slice of reservation | ||
// ids. | ||
func byteSliceToReservationIds(byteSlice []byte) ([]reservation.ID, error) { | ||
if len(byteSlice)%32 != 0 { |
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 do %reservation.IdLength
instead.
Minor cosmetic issue:
Hitting enter causes:
|
@GeorgeTsagk: review reminder |
f82d833
to
427278f
Compare
427278f
to
570bafd
Compare
8002d08
to
3ce3b9a
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.
tACK 💾
Fantastic effort @sputn1ck, can't wait to give this a go on testnet.
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.
tACK, LGTM 🎉 (pending a few nits)
Awesome work on the whole instant loopout feature 🥇 🥇
}, | ||
) | ||
if err != nil { | ||
pollPaymentTries++ |
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: I'm not sure that 50 seconds will always be enough for the payment to be accepted.
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.
polling every 15 seconds now for 20 tries, which results in 5 mins (the same as the sendpayment timeout)
"github.com/urfave/cli" | ||
) | ||
|
||
var instantOutCommand = cli.Command{ |
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.
Would be cool to have a cli command to also list available reservations. (can be a follow up).
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.
we have that loop r l
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.
Or do you mean list instantouts? (we should have that as well)
This commit updates the reservation statemachine to allow for locking and spending of the initial reservation.
3ce3b9a
to
f725f07
Compare
This PR focuses on the new instant loop out flow.
The instantout statemachine looks as follows
TODO: