server+discovery: alias-handling in gossiper
An OptionalMsgField has been added that allows outside subsystems to provide a short channel id we should insert into a ChannelUpdate that we then sign and send to our peer. When the gossiper receives a ChannelUpdate, it will query the alias manager by the passed-in FindBaseByAlias function to determine if the short channel id in the ChannelUpdate points to a known channel. If this lookup returns an error, we'll fallback to using the original id in the ChannelUpdate when querying the router. The lookup and potential fallback must occur in order to properly lock the multimutex, query the correct router channels, and rate limit the correct short channel id. An unfortunate side effect of receiving ChannelUpdates from our peer that reference on of our aliases rather than the real SCID is that we must store this policy. Yet it is not broadcast-able. Care has been taken to ensure the gossiper does not broadcast *any* ChannelUpdate with an alias SCID. The cachedNetworkMsg uses the new processedNetworkMsg struct. This is necessary so that delete-and-reinsert in the funding manager doesn't process a ChannelUpdate twice and end up in a deadlock since the err chan is no longer being used.
This commit is contained in:
4 files changed
+282
-28
No files matched your search
@@ -16,6 +16,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
@@ -734,6 +735,27 @@ func createTestCtx(startHeight uint32) (*testCtx, func(), error) {
|
||||
}
|
||||
|
||||
broadcastedMessage := make(chan msgWithSenders, 10)
|
||||
|
||||
isAlias := func(lnwire.ShortChannelID) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
signAliasUpdate := func(*lnwire.ChannelUpdate) (*ecdsa.Signature,
|
||||
error) {
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
findBaseByAlias := func(lnwire.ShortChannelID) (lnwire.ShortChannelID,
|
||||
error) {
|
||||
|
||||
return lnwire.ShortChannelID{}, fmt.Errorf("no base scid")
|
||||
}
|
||||
|
||||
getAlias := func(lnwire.ChannelID) (lnwire.ShortChannelID, error) {
|
||||
return lnwire.ShortChannelID{}, fmt.Errorf("no peer alias")
|
||||
}
|
||||
|
||||
gossiper := New(Config{
|
||||
Notifier: notifier,
|
||||
Broadcast: func(senders map[route.Vertex]struct{},
|
||||
@@ -778,6 +800,10 @@ func createTestCtx(startHeight uint32) (*testCtx, func(), error) {
|
||||
MinimumBatchSize: 10,
|
||||
MaxChannelUpdateBurst: DefaultMaxChannelUpdateBurst,
|
||||
ChannelUpdateInterval: DefaultChannelUpdateInterval,
|
||||
IsAlias: isAlias,
|
||||
SignAliasUpdate: signAliasUpdate,
|
||||
FindBaseByAlias: findBaseByAlias,
|
||||
GetAlias: getAlias,
|
||||
}, selfKeyDesc)
|
||||
|
||||
if err := gossiper.Start(); err != nil {
|
||||
@@ -1387,6 +1413,27 @@ func TestSignatureAnnouncementRetryAtStartup(t *testing.T) {
|
||||
// NotifyWhenOffline methods. This should trigger a new attempt to send
|
||||
// the message to the peer.
|
||||
ctx.gossiper.Stop()
|
||||
|
||||
isAlias := func(lnwire.ShortChannelID) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
signAliasUpdate := func(*lnwire.ChannelUpdate) (*ecdsa.Signature,
|
||||
error) {
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
findBaseByAlias := func(lnwire.ShortChannelID) (lnwire.ShortChannelID,
|
||||
error) {
|
||||
|
||||
return lnwire.ShortChannelID{}, fmt.Errorf("no base scid")
|
||||
}
|
||||
|
||||
getAlias := func(lnwire.ChannelID) (lnwire.ShortChannelID, error) {
|
||||
return lnwire.ShortChannelID{}, fmt.Errorf("no peer alias")
|
||||
}
|
||||
|
||||
gossiper := New(Config{
|
||||
Notifier: ctx.gossiper.cfg.Notifier,
|
||||
Broadcast: ctx.gossiper.cfg.Broadcast,
|
||||
@@ -1405,6 +1452,10 @@ func TestSignatureAnnouncementRetryAtStartup(t *testing.T) {
|
||||
NumActiveSyncers: 3,
|
||||
MinimumBatchSize: 10,
|
||||
SubBatchDelay: time.Second * 5,
|
||||
IsAlias: isAlias,
|
||||
SignAliasUpdate: signAliasUpdate,
|
||||
FindBaseByAlias: findBaseByAlias,
|
||||
GetAlias: getAlias,
|
||||
}, &keychain.KeyDescriptor{
|
||||
PubKey: ctx.gossiper.selfKey,
|
||||
KeyLocator: ctx.gossiper.selfKeyLoc,
|
||||
|
||||
Reference in new issue
Block a user