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

Cleanup piecemeal #90

Closed
wants to merge 33 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ac983a8
lnwire: make MuSig2Nonce TLV type re-usable
ellemouton Sep 29, 2023
780e7d6
lnwire: add RawFeatureVectorRecordProducer
ellemouton Sep 29, 2023
10ce8d7
lnwire: add Encode and Pack methods for tlv.Records
ellemouton Sep 29, 2023
9142486
lnwire: use the RawFeatureVector record methods for ChannelType
ellemouton Sep 29, 2023
806cd22
lnwire: make ShortChannelID type re-usable
ellemouton Sep 29, 2023
76d837d
lnwire: add btc and node announcement nonces to channel_ready
ellemouton Sep 29, 2023
afda72d
lnwire: add AnnouncementSignatures2 message
ellemouton Sep 29, 2023
1f43334
lnwire: add ChannelAnnouncement2 message
ellemouton Sep 29, 2023
457cca4
lnwire: introduce the BooleanRecordProducer
ellemouton Sep 29, 2023
69fb24d
lnwire: add ChannelUpdate2
ellemouton Sep 29, 2023
efff6f2
lnwire: add NodeAnnouncement2
ellemouton Sep 29, 2023
f811611
multi: rename lnwire.ChannelAnnouncement
ellemouton Oct 17, 2023
77d6c01
multi: rename channeldb.ChannelEdgeInfo to ChannelEdgeInfo1
ellemouton Oct 17, 2023
04735a0
multi: rename ChannelAuthProof to ChannelAuthProof1
ellemouton Oct 17, 2023
4a13833
lnwire: add the ChannelAnnouncement interface
ellemouton Oct 17, 2023
04d9eed
multi: use ChannelAnnouncement interface where possible
ellemouton Oct 17, 2023
e66196a
multi: remove kvdb.Backend from channeldb.LightningNode
ellemouton Oct 17, 2023
c461d7c
multi: remove kvdb.Backend from ChannelEdgeInfo
ellemouton Oct 17, 2023
711f41d
channeldb: add ChannelEdgeInfo interface
ellemouton Oct 17, 2023
53ffc11
multi: use the ChannelEdgeInfo interface everywhere
ellemouton Oct 17, 2023
7763e1a
channeldb: prepare for reading new types of ChannelEdgeInfo
ellemouton Oct 17, 2023
2ffd49e
multi: rename lnwire.ChannelUpdate
ellemouton Oct 17, 2023
1e311bc
multi: rename ChannelEdgePolicy
ellemouton Oct 17, 2023
9eea292
temp: add ChannelUpdate interface
ellemouton Oct 17, 2023
f03e646
multi: use ChannelUpdate interface for failure messages
ellemouton Oct 18, 2023
e54aac3
channeldb: add ChannelEdgeInfo2 impl
ellemouton Oct 19, 2023
923f9c3
introduce ChannelEdgePolicyWithNode
ellemouton Oct 19, 2023
4317a97
multi: pass MessageSignerKeyring to funding manager
ellemouton Oct 19, 2023
dd6d924
multi: add SignSchnorr to MessageSignerKeyring
ellemouton Oct 19, 2023
33630f2
lnwire: let ChannelUpdate2 implement ChannelUpdate
ellemouton Oct 19, 2023
5489428
netann: update to use ChannelUpdate interface
ellemouton Oct 19, 2023
7adbe6a
channeldb: prep for new ChanEdgePolicy encoding
ellemouton Oct 20, 2023
2b691cd
channeldb: ChannelEdgePolicy2 encoding
ellemouton Oct 20, 2023
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
Prev Previous commit
Next Next commit
multi: rename lnwire.ChannelAnnouncement
Rename lnwire.ChannelAnnouncement to ChannelAnnouncement1. This is in
preparation for the addition of a ChannelAnnouncement interface which
will be implemented by both ChannelAnnouncement1 and
ChannelAnnouncement2.
  • Loading branch information
ellemouton committed Oct 20, 2023
commit f811611c765aa286f6e08e3498d91d76078db60d
40 changes: 20 additions & 20 deletions discovery/gossiper.go
Original file line number Diff line number Diff line change
@@ -420,7 +420,7 @@ type AuthenticatedGossiper struct {
// prematureChannelUpdates is a map of ChannelUpdates we have received
// that wasn't associated with any channel we know about. We store
// them temporarily, such that we can reprocess them when a
// ChannelAnnouncement for the channel is received.
// ChannelAnnouncement1 for the channel is received.
prematureChannelUpdates *lru.Cache[uint64, *cachedNetworkMsg]

// networkMsgs is a channel that carries new network broadcasted
@@ -818,9 +818,9 @@ func (d *AuthenticatedGossiper) ProcessRemoteAnnouncement(msg lnwire.Message,
// To avoid inserting edges in the graph for our own channels that we
// have already closed, we ignore such channel announcements coming
// from the remote.
case *lnwire.ChannelAnnouncement:
case *lnwire.ChannelAnnouncement1:
ownKey := d.selfKey.SerializeCompressed()
ownErr := fmt.Errorf("ignoring remote ChannelAnnouncement " +
ownErr := fmt.Errorf("ignoring remote ChannelAnnouncement1 " +
"for own channel")

if bytes.Equal(m.NodeID1[:], ownKey) ||
@@ -980,7 +980,7 @@ func (d *deDupedAnnouncements) addMsg(message networkMsg) {
switch msg := message.msg.(type) {

// Channel announcements are identified by the short channel id field.
case *lnwire.ChannelAnnouncement:
case *lnwire.ChannelAnnouncement1:
deDupKey := msg.ShortChannelID
sender := route.NewVertex(message.source)

@@ -1554,7 +1554,7 @@ func (d *AuthenticatedGossiper) isRecentlyRejectedMsg(msg lnwire.Message,
case *lnwire.ChannelUpdate:
scid = m.ShortChannelID.ToUint64()

case *lnwire.ChannelAnnouncement:
case *lnwire.ChannelAnnouncement1:
scid = m.ShortChannelID.ToUint64()

default:
@@ -1810,9 +1810,9 @@ func remotePubFromChanInfo(chanInfo *channeldb.ChannelEdgeInfo,
// contains a proof, we can add this proof to our edge. We can end up in this
// situation in the case where we create a channel, but for some reason fail
// to receive the remote peer's proof, while the remote peer is able to fully
// assemble the proof and craft the ChannelAnnouncement.
// assemble the proof and craft the ChannelAnnouncement1.
func (d *AuthenticatedGossiper) processRejectedEdge(
chanAnnMsg *lnwire.ChannelAnnouncement,
chanAnnMsg *lnwire.ChannelAnnouncement1,
proof *channeldb.ChannelAuthProof) ([]networkMsg, error) {

// First, we'll fetch the state of the channel as we know if from the
@@ -1997,7 +1997,7 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(
// *creation* of a new channel within the network. This only advertises
// the existence of a channel and not yet the routing policies in
// either direction of the channel.
case *lnwire.ChannelAnnouncement:
case *lnwire.ChannelAnnouncement1:
return d.handleChanAnnouncement(nMsg, msg, schedulerOp)

// A new authenticated channel edge update has arrived. This indicates
@@ -2151,7 +2151,7 @@ func (d *AuthenticatedGossiper) isMsgStale(msg lnwire.Message) bool {
// updateChannel creates a new fully signed update for the channel, and updates
// the underlying graph with the new state.
func (d *AuthenticatedGossiper) updateChannel(info *channeldb.ChannelEdgeInfo,
edge *channeldb.ChannelEdgePolicy) (*lnwire.ChannelAnnouncement,
edge *channeldb.ChannelEdgePolicy) (*lnwire.ChannelAnnouncement1,
*lnwire.ChannelUpdate, error) {

// Parse the unsigned edge into a channel update.
@@ -2188,10 +2188,10 @@ func (d *AuthenticatedGossiper) updateChannel(info *channeldb.ChannelEdgeInfo,
// We'll also create the original channel announcement so the two can
// be broadcast along side each other (if necessary), but only if we
// have a full channel announcement for this channel.
var chanAnn *lnwire.ChannelAnnouncement
var chanAnn *lnwire.ChannelAnnouncement1
if info.AuthProof != nil {
chanID := lnwire.NewShortChanIDFromInt(info.ChannelID)
chanAnn = &lnwire.ChannelAnnouncement{
chanAnn = &lnwire.ChannelAnnouncement1{
ShortChannelID: chanID,
NodeID1: info.NodeKey1Bytes,
NodeID2: info.NodeKey2Bytes,
@@ -2363,16 +2363,16 @@ func (d *AuthenticatedGossiper) handleNodeAnnouncement(nMsg *networkMsg,

// handleChanAnnouncement processes a new channel announcement.
func (d *AuthenticatedGossiper) handleChanAnnouncement(nMsg *networkMsg,
ann *lnwire.ChannelAnnouncement,
ann *lnwire.ChannelAnnouncement1,
ops []batch.SchedulerOption) ([]networkMsg, bool) {

log.Debugf("Processing ChannelAnnouncement: peer=%v, short_chan_id=%v",
log.Debugf("Processing ChannelAnnouncement1: peer=%v, short_chan_id=%v",
nMsg.peer, ann.ShortChannelID.ToUint64())

// We'll ignore any channel announcements that target any chain other
// than the set of chains we know of.
if !bytes.Equal(ann.ChainHash[:], d.cfg.ChainHash[:]) {
err := fmt.Errorf("ignoring ChannelAnnouncement from chain=%v"+
err := fmt.Errorf("ignoring ChannelAnnouncement1 from chain=%v"+
", gossiper on chain=%v", ann.ChainHash,
d.cfg.ChainHash)
log.Errorf(err.Error())
@@ -2387,7 +2387,7 @@ func (d *AuthenticatedGossiper) handleChanAnnouncement(nMsg *networkMsg,
return nil, false
}

// If this is a remote ChannelAnnouncement with an alias SCID, we'll
// If this is a remote ChannelAnnouncement1 with an alias SCID, we'll
// reject the announcement. Since the router accepts alias SCIDs,
// not erroring out would be a DoS vector.
if nMsg.isRemote && d.cfg.IsAlias(ann.ShortChannelID) {
@@ -2630,7 +2630,7 @@ func (d *AuthenticatedGossiper) handleChanAnnouncement(nMsg *networkMsg,

nMsg.err <- nil

log.Debugf("Processed ChannelAnnouncement: peer=%v, short_chan_id=%v",
log.Debugf("Processed ChannelAnnouncement1: peer=%v, short_chan_id=%v",
nMsg.peer, ann.ShortChannelID.ToUint64())

return announcements, true
@@ -2738,7 +2738,7 @@ func (d *AuthenticatedGossiper) handleChanUpdate(nMsg *networkMsg,
}

// We'll fallthrough to ensure we stash the update until we
// receive its corresponding ChannelAnnouncement. This is
// receive its corresponding ChannelAnnouncement1. This is
// needed to ensure the edge exists in the graph before
// applying the update.
fallthrough
@@ -2750,15 +2750,15 @@ func (d *AuthenticatedGossiper) handleChanUpdate(nMsg *networkMsg,
// If the edge corresponding to this ChannelUpdate was not
// found in the graph, this might be a channel in the process
// of being opened, and we haven't processed our own
// ChannelAnnouncement yet, hence it is not not found in the
// ChannelAnnouncement yet, hence it is not found in the
// graph. This usually gets resolved after the channel proofs
// are exchanged and the channel is broadcasted to the rest of
// the network, but in case this is a private channel this
// won't ever happen. This can also happen in the case of a
// zombie channel with a fresh update for which we don't have a
// ChannelAnnouncement for since we reject them. Because of
// ChannelAnnouncement1 for since we reject them. Because of
// this, we temporarily add it to a map, and reprocess it after
// our own ChannelAnnouncement has been processed.
// our own ChannelAnnouncement1 has been processed.
//
// The shortChanID may be an alias, but it is fine to use here
// since we don't have an edge in the graph and if the peer is
33 changes: 16 additions & 17 deletions discovery/gossiper_test.go
Original file line number Diff line number Diff line change
@@ -464,7 +464,7 @@ type annBatch struct {
nodeAnn1 *lnwire.NodeAnnouncement
nodeAnn2 *lnwire.NodeAnnouncement

chanAnn *lnwire.ChannelAnnouncement
chanAnn *lnwire.ChannelAnnouncement1

chanUpdAnn1 *lnwire.ChannelUpdate
chanUpdAnn2 *lnwire.ChannelUpdate
@@ -623,9 +623,9 @@ func signUpdate(nodeKey *btcec.PrivateKey, a *lnwire.ChannelUpdate) error {

func createAnnouncementWithoutProof(blockHeight uint32,
key1, key2 *btcec.PublicKey,
extraBytes ...[]byte) *lnwire.ChannelAnnouncement {
extraBytes ...[]byte) *lnwire.ChannelAnnouncement1 {

a := &lnwire.ChannelAnnouncement{
a := &lnwire.ChannelAnnouncement1{
ShortChannelID: lnwire.ShortChannelID{
BlockHeight: blockHeight,
TxIndex: 0,
@@ -645,13 +645,13 @@ func createAnnouncementWithoutProof(blockHeight uint32,
}

func createRemoteChannelAnnouncement(blockHeight uint32,
extraBytes ...[]byte) (*lnwire.ChannelAnnouncement, error) {
extraBytes ...[]byte) (*lnwire.ChannelAnnouncement1, error) {

return createChannelAnnouncement(blockHeight, remoteKeyPriv1, remoteKeyPriv2, extraBytes...)
}

func createChannelAnnouncement(blockHeight uint32, key1, key2 *btcec.PrivateKey,
extraBytes ...[]byte) (*lnwire.ChannelAnnouncement, error) {
extraBytes ...[]byte) (*lnwire.ChannelAnnouncement1, error) {

a := createAnnouncementWithoutProof(blockHeight, key1.PubKey(), key2.PubKey(), extraBytes...)

@@ -1566,7 +1566,7 @@ out:

// TestSignatureAnnouncementFullProofWhenRemoteProof tests that if a remote
// proof is received when we already have the full proof, the gossiper will send
// the full proof (ChannelAnnouncement) to the remote peer.
// the full proof (ChannelAnnouncement1) to the remote peer.
func TestSignatureAnnouncementFullProofWhenRemoteProof(t *testing.T) {
t.Parallel()

@@ -1728,7 +1728,7 @@ func TestSignatureAnnouncementFullProofWhenRemoteProof(t *testing.T) {
}

// Now give the gossiper the remote proof yet again. This should
// trigger a send of the full ChannelAnnouncement.
// trigger a send of the full ChannelAnnouncement1.
select {
case err = <-ctx.gossiper.ProcessRemoteAnnouncement(
batch.remoteProofAnn, remotePeer,
@@ -1741,10 +1741,9 @@ func TestSignatureAnnouncementFullProofWhenRemoteProof(t *testing.T) {
// We expect the gossiper to send this message to the remote peer.
select {
case msg := <-sentToPeer:
_, ok := msg.(*lnwire.ChannelAnnouncement)
if !ok {
t.Fatalf("expected ChannelAnnouncement, instead got %T", msg)
}
_, ok := msg.(*lnwire.ChannelAnnouncement1)
require.Truef(t, ok,
"expected ChannelAnnouncement1, instead got %T", msg)
case <-time.After(2 * time.Second):
t.Fatal("did not send local proof to peer")
}
@@ -2058,7 +2057,7 @@ func TestForwardPrivateNodeAnnouncement(t *testing.T) {

// Now, we'll attempt to forward the NodeAnnouncement for the same node
// by opening a public channel on the network. We'll create a
// ChannelAnnouncement and hand it off to the gossiper in order to
// ChannelAnnouncement1 and hand it off to the gossiper in order to
// process it.
remoteChanAnn, err := createRemoteChannelAnnouncement(startingHeight - 1)
require.NoError(t, err, "unable to create remote channel announcement")
@@ -2360,8 +2359,8 @@ func TestProcessZombieEdgeNowLive(t *testing.T) {
}

// TestReceiveRemoteChannelUpdateFirst tests that if we receive a ChannelUpdate
// from the remote before we have processed our own ChannelAnnouncement, it will
// be reprocessed later, after our ChannelAnnouncement.
// from the remote before we have processed our own ChannelAnnouncement1, it will
// be reprocessed later, after our ChannelAnnouncement1.
func TestReceiveRemoteChannelUpdateFirst(t *testing.T) {
t.Parallel()

@@ -2388,7 +2387,7 @@ func TestReceiveRemoteChannelUpdateFirst(t *testing.T) {
}

// Recreate the case where the remote node is sending us its ChannelUpdate
// before we have been able to process our own ChannelAnnouncement and
// before we have been able to process our own ChannelAnnouncement1 and
// ChannelUpdate.
errRemoteAnn := ctx.gossiper.ProcessRemoteAnnouncement(
batch.chanUpdAnn2, remotePeer,
@@ -2557,7 +2556,7 @@ func TestReceiveRemoteChannelUpdateFirst(t *testing.T) {
}

// TestExtraDataChannelAnnouncementValidation tests that we're able to properly
// validate a ChannelAnnouncement that includes opaque bytes that we don't
// validate a ChannelAnnouncement1 that includes opaque bytes that we don't
// currently know of.
func TestExtraDataChannelAnnouncementValidation(t *testing.T) {
t.Parallel()
@@ -2776,7 +2775,7 @@ func TestRetransmit(t *testing.T) {
var chanAnn, chanUpd, nodeAnn int
for _, msg := range anns {
switch msg.(type) {
case *lnwire.ChannelAnnouncement:
case *lnwire.ChannelAnnouncement1:
chanAnn++
case *lnwire.ChannelUpdate:
chanUpd++
2 changes: 1 addition & 1 deletion discovery/syncer.go
Original file line number Diff line number Diff line change
@@ -1314,7 +1314,7 @@ func (g *GossipSyncer) FilterGossipMsgs(msgs ...msgWithSenders) {
// For each channel announcement message, we'll only send this
// message if the channel updates for the channel are between
// our time range.
case *lnwire.ChannelAnnouncement:
case *lnwire.ChannelAnnouncement1:
// First, we'll check if the channel updates are in
// this message batch.
chanUpdates, ok := chanUpdateIndex[msg.ShortChannelID]
10 changes: 5 additions & 5 deletions discovery/syncer_test.go
Original file line number Diff line number Diff line change
@@ -283,7 +283,7 @@ func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) {
},
{
// Ann tuple below horizon.
msg: &lnwire.ChannelAnnouncement{
msg: &lnwire.ChannelAnnouncement1{
ShortChannelID: lnwire.NewShortChanIDFromInt(10),
},
},
@@ -295,7 +295,7 @@ func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) {
},
{
// Ann tuple above horizon.
msg: &lnwire.ChannelAnnouncement{
msg: &lnwire.ChannelAnnouncement1{
ShortChannelID: lnwire.NewShortChanIDFromInt(15),
},
},
@@ -307,7 +307,7 @@ func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) {
},
{
// Ann tuple beyond horizon.
msg: &lnwire.ChannelAnnouncement{
msg: &lnwire.ChannelAnnouncement1{
ShortChannelID: lnwire.NewShortChanIDFromInt(20),
},
},
@@ -320,7 +320,7 @@ func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) {
{
// Ann w/o an update at all, the update in the DB will
// be below the horizon.
msg: &lnwire.ChannelAnnouncement{
msg: &lnwire.ChannelAnnouncement1{
ShortChannelID: lnwire.NewShortChanIDFromInt(25),
},
},
@@ -683,7 +683,7 @@ func TestGossipSyncerReplyShortChanIDs(t *testing.T) {
}

queryReply := []lnwire.Message{
&lnwire.ChannelAnnouncement{
&lnwire.ChannelAnnouncement1{
ShortChannelID: lnwire.NewShortChanIDFromInt(20),
},
&lnwire.ChannelUpdate{
16 changes: 8 additions & 8 deletions funding/manager.go
Original file line number Diff line number Diff line change
@@ -3295,7 +3295,7 @@ func (f *Manager) receivedChannelReady(node *btcec.PublicKey,
}

// extractAnnounceParams extracts the various channel announcement and update
// parameters that will be needed to construct a ChannelAnnouncement and a
// parameters that will be needed to construct a ChannelAnnouncement1 and a
// ChannelUpdate.
func (f *Manager) extractAnnounceParams(c *channeldb.OpenChannel) (
lnwire.MilliSatoshi, lnwire.MilliSatoshi) {
@@ -3324,7 +3324,7 @@ func (f *Manager) extractAnnounceParams(c *channeldb.OpenChannel) (
return fwdMinHTLC, fwdMaxHTLC
}

// addToRouterGraph sends a ChannelAnnouncement and a ChannelUpdate to the
// addToRouterGraph sends a ChannelAnnouncement1 and a ChannelUpdate to the
// gossiper so that the channel is added to the Router's internal graph.
// These announcement messages are NOT broadcasted to the greater network,
// only to the channel counter party. The proofs required to announce the
@@ -3353,7 +3353,7 @@ func (f *Manager) addToRouterGraph(completeChan *channeldb.OpenChannel,
"announcement: %v", err)
}

// Send ChannelAnnouncement and ChannelUpdate to the gossiper to add
// Send ChannelAnnouncement1 and ChannelUpdate to the gossiper to add
// to the Router's topology.
errChan := f.cfg.SendAnnouncement(
ann.chanAnn, discovery.ChannelCapacity(completeChan.Capacity),
@@ -3366,7 +3366,7 @@ func (f *Manager) addToRouterGraph(completeChan *channeldb.OpenChannel,
routing.ErrIgnored) {

log.Debugf("Router rejected "+
"ChannelAnnouncement: %v", err)
"ChannelAnnouncement1: %v", err)
} else {
return fmt.Errorf("error sending channel "+
"announcement: %v", err)
@@ -4050,7 +4050,7 @@ func (f *Manager) ensureInitialForwardingPolicy(chanID lnwire.ChannelID,
// chanAnnouncement encapsulates the two authenticated announcements that we
// send out to the network after a new channel has been created locally.
type chanAnnouncement struct {
chanAnn *lnwire.ChannelAnnouncement
chanAnn *lnwire.ChannelAnnouncement1
chanUpdateAnn *lnwire.ChannelUpdate
chanProof *lnwire.AnnounceSignatures
}
@@ -4075,7 +4075,7 @@ func (f *Manager) newChanAnnouncement(localPubKey,
// The unconditional section of the announcement is the ShortChannelID
// itself which compactly encodes the location of the funding output
// within the blockchain.
chanAnn := &lnwire.ChannelAnnouncement{
chanAnn := &lnwire.ChannelAnnouncement1{
ShortChannelID: shortChanID,
Features: lnwire.NewRawFeatureVector(),
ChainHash: chainHash,
@@ -4088,7 +4088,7 @@ func (f *Manager) newChanAnnouncement(localPubKey,
// TODO(roasbeef): temp, remove after gossip 1.5
if chanType.IsTaproot() {
log.Debugf("Applying taproot feature bit to "+
"ChannelAnnouncement for %v", chanID)
"ChannelAnnouncement1 for %v", chanID)

chanAnn.Features.Set(
lnwire.SimpleTaprootChannelsRequiredStaging,
@@ -4293,7 +4293,7 @@ func (f *Manager) announceChannel(localIDKey, remoteIDKey *btcec.PublicKey,
}

// We only send the channel proof announcement and the node announcement
// because addToRouterGraph previously sent the ChannelAnnouncement and
// because addToRouterGraph previously sent the ChannelAnnouncement1 and
// the ChannelUpdate announcement messages. The channel proof and node
// announcements are broadcast to the greater network.
errChan := f.cfg.SendAnnouncement(ann.chanProof)
Loading