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

server: start htlcswitch early in the pipeline #6214

Merged
merged 3 commits into from
Feb 24, 2022
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
2 changes: 1 addition & 1 deletion chanbackup/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func NewSubSwapper(startingChans []Single, chanNotifier ChannelNotifier,
func (s *SubSwapper) Start() error {
var startErr error
s.started.Do(func() {
log.Infof("Starting chanbackup.SubSwapper")
log.Infof("chanbackup.SubSwapper starting")

// Before we enter our main loop, we'll update the on-disk
// state with the latest Single state, as nodes may have new
Expand Down
2 changes: 2 additions & 0 deletions chanfitness/chaneventstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ func NewChannelEventStore(config *Config) *ChannelEventStore {
// information from the store. If this function fails, it cancels its existing
// subscriptions and returns an error.
func (c *ChannelEventStore) Start() error {
log.Info("ChannelEventStore starting")

// Create a subscription to channel events.
channelClient, err := c.cfg.SubscribeChannelEvents()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion channelnotifier/channelnotifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func New(chanDB *channeldb.ChannelStateDB) *ChannelNotifier {
func (c *ChannelNotifier) Start() error {
var err error
c.started.Do(func() {
log.Trace("ChannelNotifier starting")
log.Info("ChannelNotifier starting")
err = c.ntfnServer.Start()
})
return err
Expand Down
3 changes: 1 addition & 2 deletions contractcourt/breacharbiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,13 @@ func NewBreachArbiter(cfg *BreachConfig) *BreachArbiter {
func (b *BreachArbiter) Start() error {
var err error
b.started.Do(func() {
brarLog.Info("Breach arbiter starting")
err = b.start()
})
return err
}

func (b *BreachArbiter) start() error {
brarLog.Tracef("Starting breach arbiter")

// Load all retributions currently persisted in the retribution store.
var breachRetInfos map[wire.OutPoint]retributionInfo
if err := b.cfg.Store.ForAll(func(ret *retributionInfo) error {
Expand Down
2 changes: 1 addition & 1 deletion contractcourt/chain_arbitrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ func (c *ChainArbitrator) Start() error {
return nil
}

log.Tracef("Starting ChainArbitrator")
log.Info("ChainArbitrator starting")

// First, we'll fetch all the channels that are still open, in order to
// collect them within our set of active contracts.
Expand Down
2 changes: 1 addition & 1 deletion contractcourt/utxonursery.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func (u *UtxoNursery) Start() error {
return nil
}

utxnLog.Tracef("Starting UTXO nursery")
utxnLog.Info("UTXO nursery starting")

// Retrieve the currently best known block. This is needed to have the
// state machine catch up with the blocks we missed when we were down.
Expand Down
3 changes: 1 addition & 2 deletions discovery/gossiper.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,14 +498,13 @@ func (d *AuthenticatedGossiper) PropagateChanPolicyUpdate(
func (d *AuthenticatedGossiper) Start() error {
var err error
d.started.Do(func() {
log.Info("Authenticated Gossiper starting")
err = d.start()
})
return err
}

func (d *AuthenticatedGossiper) start() error {
log.Info("Authenticated Gossiper is starting")

// First we register for new notifications of newly discovered blocks.
// We do this immediately so we'll later be able to consume any/all
// blocks which were discovered.
Expand Down
4 changes: 4 additions & 0 deletions docs/release-notes/release-notes-0.15.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
could result in an "invoice too large" error when creating invoices. Hints
are now properly limited to our maximum of 20.

* [Fixed an edge case where the lnd might be stuck at starting due to channel
arbitrator relying on htlcswitch to be started
first](https://github.com/lightningnetwork/lnd/pull/6214).

## Misc

* [An example systemd service file](https://github.com/lightningnetwork/lnd/pull/6033)
Expand Down
5 changes: 2 additions & 3 deletions funding/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,14 +588,13 @@ func NewFundingManager(cfg Config) (*Manager, error) {
func (f *Manager) Start() error {
var err error
f.started.Do(func() {
log.Info("Funding manager starting")
err = f.start()
})
return err
}

func (f *Manager) start() error {
log.Tracef("Funding manager running")

// Upon restart, the Funding Manager will check the database to load any
// channels that were waiting for their funding transactions to be
// confirmed on the blockchain at the time when the daemon last went
Expand Down Expand Up @@ -1235,7 +1234,7 @@ func (f *Manager) handleFundingOpen(peer lnpeer.Peer,
if amt < f.cfg.MinChanSize {
f.failFundingFlow(
peer, msg.PendingChannelID,
lnwallet.ErrChanTooSmall(amt, btcutil.Amount(f.cfg.MinChanSize)),
lnwallet.ErrChanTooSmall(amt, f.cfg.MinChanSize),
)
return
}
Expand Down
1 change: 1 addition & 0 deletions htlcswitch/hop/iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ func NewOnionProcessor(router *sphinx.Router) *OnionProcessor {

// Start spins up the onion processor's sphinx router.
func (p *OnionProcessor) Start() error {
log.Info("Onion processor starting")
return p.router.Start()
}

Expand Down
2 changes: 1 addition & 1 deletion htlcswitch/htlcnotifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func NewHtlcNotifier(now func() time.Time) *HtlcNotifier {
func (h *HtlcNotifier) Start() error {
var err error
h.started.Do(func() {
log.Trace("HtlcNotifier starting")
log.Info("HtlcNotifier starting")
err = h.ntfnServer.Start()
})
return err
Expand Down
2 changes: 1 addition & 1 deletion htlcswitch/switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -1846,7 +1846,7 @@ func (s *Switch) Start() error {
return errors.New("htlc switch already started")
}

log.Infof("Starting HTLC Switch")
log.Infof("HTLC Switch starting")

blockEpochStream, err := s.cfg.Notifier.RegisterBlockEpochNtfn(nil)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions invoices/invoiceregistry.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ func (i *InvoiceRegistry) Start() error {
return err
}

log.Info("InvoiceRegistry starting")

i.wg.Add(1)
go i.invoiceEventLoop()

Expand Down
1 change: 1 addition & 0 deletions lnwallet/sigpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ func NewSigPool(numWorkers int, signer input.Signer) *SigPool {
// carry out its duties.
func (s *SigPool) Start() error {
s.started.Do(func() {
walletLog.Info("SigPool starting")
for i := 0; i < s.numWorkers; i++ {
s.wg.Add(1)
go s.poolWorker()
Expand Down
1 change: 1 addition & 0 deletions netann/chan_status_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ func NewChanStatusManager(cfg *ChanStatusConfig) (*ChanStatusManager, error) {
func (m *ChanStatusManager) Start() error {
var err error
m.started.Do(func() {
log.Info("Channel Status Manager starting")
err = m.start()
})
return err
Expand Down
1 change: 1 addition & 0 deletions netann/host_ann.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func NewHostAnnouncer(cfg HostAnnouncerConfig) *HostAnnouncer {
// Start starts the HostAnnouncer.
func (h *HostAnnouncer) Start() error {
h.startOnce.Do(func() {
log.Info("HostAnnouncer starting")
h.wg.Add(1)
go h.hostWatcher()
})
Expand Down
2 changes: 1 addition & 1 deletion routing/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ func (r *ChannelRouter) Start() error {
return nil
}

log.Tracef("Channel Router starting")
log.Info("Channel Router starting")

bestHash, bestHeight, err := r.cfg.Chain.GetBestBlock()
if err != nil {
Expand Down
15 changes: 9 additions & 6 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1777,6 +1777,15 @@ func (s *server) Start() error {
}
cleanup = cleanup.add(s.fundingMgr.Stop)

// htlcSwitch must be started before chainArb since the latter
// relies on htlcSwitch to deliver resolution message upon
// start.
if err := s.htlcSwitch.Start(); err != nil {
startErr = err
return
}
cleanup = cleanup.add(s.htlcSwitch.Stop)

if err := s.chainArb.Start(); err != nil {
startErr = err
return
Expand Down Expand Up @@ -1807,12 +1816,6 @@ func (s *server) Start() error {
}
cleanup = cleanup.add(s.sphinx.Stop)

if err := s.htlcSwitch.Start(); err != nil {
startErr = err
return
}
cleanup = cleanup.add(s.htlcSwitch.Stop)

if err := s.chanStatusMgr.Start(); err != nil {
startErr = err
return
Expand Down
2 changes: 1 addition & 1 deletion sweep/sweeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ func (s *UtxoSweeper) Start() error {
return nil
}

log.Tracef("Sweeper starting")
log.Info("Sweeper starting")

// Retrieve last published tx from database.
lastTx, err := s.cfg.Store.GetLastPublishedTx()
Expand Down
2 changes: 1 addition & 1 deletion watchtower/wtclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ func (c *TowerClient) buildHighestCommitHeights() {
func (c *TowerClient) Start() error {
var err error
c.started.Do(func() {
c.log.Infof("Starting watchtower client")
c.log.Infof("Watchtower client starting")

// First, restart a session queue for any sessions that have
// committed but unacked state updates. This ensures that these
Expand Down