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

contractcourt: modify the incoming contest resolver to use concurrent… #8024

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions contractcourt/htlc_incoming_contest_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/queue"
)

// htlcIncomingContestResolver is a ContractResolver that's able to resolve an
Expand Down Expand Up @@ -283,12 +284,15 @@ func (h *htlcIncomingContestResolver) Resolve() (ContractResolver, error) {
}

var (
hodlChan chan interface{}
hodlChan <-chan interface{}
witnessUpdates <-chan lntypes.Preimage
)
if payload.FwdInfo.NextHop == hop.Exit {
// Create a buffered hodl chan to prevent deadlock.
hodlChan = make(chan interface{}, 1)
hodlQueue := queue.NewConcurrentQueue(10)
hodlQueue.Start()

hodlChan = hodlQueue.ChanOut()

// Notify registry that we are potentially resolving as an exit
// hop on-chain. If this HTLC indeed pays to an existing
Expand All @@ -301,13 +305,17 @@ func (h *htlcIncomingContestResolver) Resolve() (ContractResolver, error) {

resolution, err := h.Registry.NotifyExitHopHtlc(
h.htlc.RHash, h.htlc.Amt, h.htlcExpiry, currentHeight,
circuitKey, hodlChan, payload,
circuitKey, hodlQueue.ChanIn(), payload,
)
if err != nil {
return nil, err
}

defer h.Registry.HodlUnsubscribeAll(hodlChan)
defer func() {
h.Registry.HodlUnsubscribeAll(hodlQueue.ChanIn())

hodlQueue.Stop()
}()

// Take action based on the resolution we received. If the htlc
// was settled, or a htlc for a known invoice failed we can
Expand Down
5 changes: 5 additions & 0 deletions docs/release-notes/release-notes-0.17.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ fails](https://github.com/lightningnetwork/lnd/pull/7876).
* `lnd` [now properly handles a case where an erroneous force close attempt
would impeded start up](https://github.com/lightningnetwork/lnd/pull/7985).

* A bug that could cause the invoice related sub-system to lock up (potentially
the entire daemon) related to [incoming HTLCs going on chain related to a
hodl invoice has been
fixed](https://github.com/lightningnetwork/lnd/pull/8024).

# New Features
## Functional Enhancements

Expand Down
Loading