peer+funding: remove unneeded channel handoff code with the breach arbiter
We no longer need to hand off new channels that come online as the chainWatcher will be persistent, and always have an active signal for the entire lifetime of the channel.
This commit is contained in:
parent
a0cc1d1b2d
commit
69e6ec9954
@ -1019,7 +1019,7 @@ func (d *AuthenticatedGossiper) retransmitStaleChannels() error {
|
|||||||
// existence.
|
// existence.
|
||||||
if info.AuthProof == nil {
|
if info.AuthProof == nil {
|
||||||
log.Debugf("Skipping retransmission of channel "+
|
log.Debugf("Skipping retransmission of channel "+
|
||||||
"without AuthProof: %v", info)
|
"without AuthProof: %v", info.ChannelID)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,12 +164,6 @@ type fundingConfig struct {
|
|||||||
// transaction information.
|
// transaction information.
|
||||||
FeeEstimator lnwallet.FeeEstimator
|
FeeEstimator lnwallet.FeeEstimator
|
||||||
|
|
||||||
// ArbiterChan allows the FundingManager to notify the BreachArbiter
|
|
||||||
// that a new channel has been created that should be observed to
|
|
||||||
// ensure that the channel counterparty hasn't broadcast an invalid
|
|
||||||
// commitment transaction.
|
|
||||||
ArbiterChan chan<- *lnwallet.LightningChannel
|
|
||||||
|
|
||||||
// Notifier is used by the FundingManager to determine when the
|
// Notifier is used by the FundingManager to determine when the
|
||||||
// channel's funding transaction has been confirmed on the blockchain
|
// channel's funding transaction has been confirmed on the blockchain
|
||||||
// so that the channel creation process can be completed.
|
// so that the channel creation process can be completed.
|
||||||
@ -235,13 +229,11 @@ type fundingConfig struct {
|
|||||||
// contract breach.
|
// contract breach.
|
||||||
RequiredRemoteDelay func(btcutil.Amount) uint16
|
RequiredRemoteDelay func(btcutil.Amount) uint16
|
||||||
|
|
||||||
// ArbitrateNewChan is to be called once a new channel enters the final
|
// WatchNewChannel is to be called once a new channel enters the final
|
||||||
// funding stage: waiting for on-chain confirmation. This method sends
|
// funding stage: waiting for on-chain confirmation. This method sends
|
||||||
// the channel to the ChainArbitrator so it can watch for any on-chain
|
// the channel to the ChainArbitrator so it can watch for any on-chain
|
||||||
// events related to the channel.
|
// events related to the channel.
|
||||||
//
|
WatchNewChannel func(*channeldb.OpenChannel) error
|
||||||
// TODO(roasbeef): pass signal as well?
|
|
||||||
ArbitrateNewChan func(*channeldb.OpenChannel) error
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// fundingManager acts as an orchestrator/bridge between the wallet's
|
// fundingManager acts as an orchestrator/bridge between the wallet's
|
||||||
@ -1209,7 +1201,7 @@ func (f *fundingManager) handleFundingCreated(fmsg *fundingCreatedMsg) {
|
|||||||
// Now that we've sent over our final signature for this channel, we'll
|
// Now that we've sent over our final signature for this channel, we'll
|
||||||
// send it to the ChainArbitrator so it can watch for any on-chain
|
// send it to the ChainArbitrator so it can watch for any on-chain
|
||||||
// actions during this final confirmation stage.
|
// actions during this final confirmation stage.
|
||||||
if err := f.cfg.ArbitrateNewChan(completeChan); err != nil {
|
if err := f.cfg.WatchNewChannel(completeChan); err != nil {
|
||||||
fndgLog.Error("Unable to send new ChannelPoint(%v) for "+
|
fndgLog.Error("Unable to send new ChannelPoint(%v) for "+
|
||||||
"arbitration", fundingOut)
|
"arbitration", fundingOut)
|
||||||
}
|
}
|
||||||
@ -1348,9 +1340,7 @@ func (f *fundingManager) handleFundingSigned(fmsg *fundingSignedMsg) {
|
|||||||
// we'll send the to be active channel to the ChainArbitrator so it can
|
// we'll send the to be active channel to the ChainArbitrator so it can
|
||||||
// watch for any on-chin actions before the channel has fully
|
// watch for any on-chin actions before the channel has fully
|
||||||
// confirmed.
|
// confirmed.
|
||||||
//
|
if err := f.cfg.WatchNewChannel(completeChan); err != nil {
|
||||||
// TODO(roasbeef): ensure later it also gets new signals
|
|
||||||
if err := f.cfg.ArbitrateNewChan(completeChan); err != nil {
|
|
||||||
fndgLog.Error("Unable to send new ChannelPoint(%v) for "+
|
fndgLog.Error("Unable to send new ChannelPoint(%v) for "+
|
||||||
"arbitration", fundingPoint)
|
"arbitration", fundingPoint)
|
||||||
}
|
}
|
||||||
@ -1407,7 +1397,7 @@ func (f *fundingManager) handleFundingSigned(fmsg *fundingSignedMsg) {
|
|||||||
// Go on adding the channel to the channel graph, and crafting
|
// Go on adding the channel to the channel graph, and crafting
|
||||||
// channel announcements.
|
// channel announcements.
|
||||||
lnChannel, err := lnwallet.NewLightningChannel(
|
lnChannel, err := lnwallet.NewLightningChannel(
|
||||||
nil, nil, nil, completeChan,
|
nil, nil, completeChan,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fndgLog.Errorf("failed creating lnChannel: %v", err)
|
fndgLog.Errorf("failed creating lnChannel: %v", err)
|
||||||
@ -1415,7 +1405,6 @@ func (f *fundingManager) handleFundingSigned(fmsg *fundingSignedMsg) {
|
|||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
lnChannel.Stop()
|
lnChannel.Stop()
|
||||||
lnChannel.CancelObserver()
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
err = f.sendFundingLocked(completeChan, lnChannel, shortChanID)
|
err = f.sendFundingLocked(completeChan, lnChannel, shortChanID)
|
||||||
@ -1654,14 +1643,13 @@ func (f *fundingManager) handleFundingConfirmation(completeChan *channeldb.OpenC
|
|||||||
|
|
||||||
// We create the state-machine object which wraps the database state.
|
// We create the state-machine object which wraps the database state.
|
||||||
lnChannel, err := lnwallet.NewLightningChannel(
|
lnChannel, err := lnwallet.NewLightningChannel(
|
||||||
nil, nil, nil, completeChan,
|
nil, nil, completeChan,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
lnChannel.Stop()
|
lnChannel.Stop()
|
||||||
lnChannel.CancelObserver()
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&completeChan.FundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(&completeChan.FundingOutpoint)
|
||||||
@ -1993,16 +1981,6 @@ func (f *fundingManager) handleFundingLocked(fmsg *fundingLockedMsg) {
|
|||||||
fndgLog.Infof("Received duplicate fundingLocked for "+
|
fndgLog.Infof("Received duplicate fundingLocked for "+
|
||||||
"ChannelID(%v), ignoring.", chanID)
|
"ChannelID(%v), ignoring.", chanID)
|
||||||
channel.Stop()
|
channel.Stop()
|
||||||
channel.CancelObserver()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// With the channel retrieved, we'll send the breach arbiter the new
|
|
||||||
// channel so it can watch for attempts to breach the channel's
|
|
||||||
// contract by the remote party.
|
|
||||||
select {
|
|
||||||
case f.cfg.ArbiterChan <- channel:
|
|
||||||
case <-f.quit:
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
lnd.go
6
lnd.go
@ -268,7 +268,6 @@ func lndMain() error {
|
|||||||
idPrivKey.PubKey())
|
idPrivKey.PubKey())
|
||||||
return <-errChan
|
return <-errChan
|
||||||
},
|
},
|
||||||
ArbiterChan: server.breachArbiter.newContracts,
|
|
||||||
SendToPeer: server.SendToPeer,
|
SendToPeer: server.SendToPeer,
|
||||||
NotifyWhenOnline: server.NotifyWhenOnline,
|
NotifyWhenOnline: server.NotifyWhenOnline,
|
||||||
FindPeer: server.FindPeer,
|
FindPeer: server.FindPeer,
|
||||||
@ -284,7 +283,6 @@ func lndMain() error {
|
|||||||
// TODO(rosbeef): populate baecon
|
// TODO(rosbeef): populate baecon
|
||||||
return lnwallet.NewLightningChannel(
|
return lnwallet.NewLightningChannel(
|
||||||
activeChainControl.signer,
|
activeChainControl.signer,
|
||||||
activeChainControl.chainNotifier,
|
|
||||||
server.witnessBeacon,
|
server.witnessBeacon,
|
||||||
channel)
|
channel)
|
||||||
}
|
}
|
||||||
@ -359,9 +357,7 @@ func lndMain() error {
|
|||||||
}
|
}
|
||||||
return delay
|
return delay
|
||||||
},
|
},
|
||||||
ArbitrateNewChan: func(c *channeldb.OpenChannel) error {
|
WatchNewChannel: server.chainArb.WatchNewChannel,
|
||||||
return server.chainArb.RequestChannelArbitration(c)
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
20
peer.go
20
peer.go
@ -312,14 +312,6 @@ func (p *peer) loadActiveChannels(chans []*channeldb.OpenChannel) error {
|
|||||||
|
|
||||||
peerLog.Infof("peerID(%v) loading ChannelPoint(%v)", p.id, chanPoint)
|
peerLog.Infof("peerID(%v) loading ChannelPoint(%v)", p.id, chanPoint)
|
||||||
|
|
||||||
select {
|
|
||||||
case p.server.breachArbiter.newContracts <- lnChan:
|
|
||||||
case <-p.server.quit:
|
|
||||||
return fmt.Errorf("server shutting down")
|
|
||||||
case <-p.quit:
|
|
||||||
return fmt.Errorf("peer shutting down")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip adding any permanently irreconcilable channels to the
|
// Skip adding any permanently irreconcilable channels to the
|
||||||
// htlcswitch.
|
// htlcswitch.
|
||||||
if dbChan.IsBorked {
|
if dbChan.IsBorked {
|
||||||
@ -1220,18 +1212,6 @@ out:
|
|||||||
p.activeChanMtx.Unlock()
|
p.activeChanMtx.Unlock()
|
||||||
close(newChanReq.done)
|
close(newChanReq.done)
|
||||||
newChanReq.channel.Stop()
|
newChanReq.channel.Stop()
|
||||||
newChanReq.channel.CancelObserver()
|
|
||||||
|
|
||||||
// We'll re-send our current channel to the
|
|
||||||
// breachArbiter to ensure that it has the most
|
|
||||||
// up to date version.
|
|
||||||
select {
|
|
||||||
case p.server.breachArbiter.newContracts <- currentChan:
|
|
||||||
case <-p.server.quit:
|
|
||||||
return
|
|
||||||
case <-p.quit:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we're being sent a new channel, and our
|
// If we're being sent a new channel, and our
|
||||||
// existing channel doesn't have the next
|
// existing channel doesn't have the next
|
||||||
|
@ -825,7 +825,6 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
channel.Stop()
|
channel.Stop()
|
||||||
channel.CancelObserver()
|
|
||||||
|
|
||||||
_, bestHeight, err := r.server.cc.chainIO.GetBestBlock()
|
_, bestHeight, err := r.server.cc.chainIO.GetBestBlock()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -986,7 +985,7 @@ func (r *rpcServer) fetchActiveChannel(chanPoint wire.OutPoint) (*lnwallet.Light
|
|||||||
// Otherwise, we create a fully populated channel state machine which
|
// Otherwise, we create a fully populated channel state machine which
|
||||||
// uses the db channel as backing storage.
|
// uses the db channel as backing storage.
|
||||||
return lnwallet.NewLightningChannel(
|
return lnwallet.NewLightningChannel(
|
||||||
r.server.cc.wallet.Cfg.Signer, nil, nil, dbChan,
|
r.server.cc.wallet.Cfg.Signer, nil, dbChan,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user