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
Show file tree
Hide file tree
Changes from all commits
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
68 changes: 42 additions & 26 deletions autopilot/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
"github.com/btcsuite/btcd/btcutil"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/channeldb/models"
"github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing/route"
Expand Down Expand Up @@ -53,6 +54,8 @@ func ChannelGraphFromDatabase(db *channeldb.ChannelGraph) ChannelGraph {
// channeldb.LightningNode. The wrapper method implement the autopilot.Node
// interface.
type dbNode struct {
db kvdb.Backend

tx kvdb.RTx

node *channeldb.LightningNode
Expand Down Expand Up @@ -86,8 +89,9 @@ func (d dbNode) Addrs() []net.Addr {
//
// NOTE: Part of the autopilot.Node interface.
func (d dbNode) ForEachChannel(cb func(ChannelEdge) error) error {
return d.node.ForEachChannel(d.tx, func(tx kvdb.RTx,
ei *channeldb.ChannelEdgeInfo, ep, _ *channeldb.ChannelEdgePolicy) error {
return d.node.ForEachChannel(d.db, d.tx, func(db kvdb.Backend,
tx kvdb.RTx, ei models.ChannelEdgeInfo, ep,
_ *channeldb.ChannelEdgePolicyWithNode) error {

// Skip channels for which no outgoing edge policy is available.
//
Expand All @@ -102,8 +106,9 @@ func (d dbNode) ForEachChannel(cb func(ChannelEdge) error) error {

edge := ChannelEdge{
ChanID: lnwire.NewShortChanIDFromInt(ep.ChannelID),
Capacity: ei.Capacity,
Capacity: ei.GetCapacity(),
Peer: dbNode{
db: db,
tx: tx,
node: ep.Node,
},
Expand All @@ -128,6 +133,7 @@ func (d *databaseChannelGraph) ForEachNode(cb func(Node) error) error {
}

node := dbNode{
db: d.db.DB(),
tx: tx,
node: n,
}
Expand Down Expand Up @@ -222,41 +228,49 @@ func (d *databaseChannelGraph) addRandChannel(node1, node2 *btcec.PublicKey,
}

chanID := randChanID()
edge := &channeldb.ChannelEdgeInfo{
edge := &channeldb.ChannelEdgeInfo1{
ChannelID: chanID.ToUint64(),
Capacity: capacity,
}
edge.AddNodeKeys(lnNode1, lnNode2, lnNode1, lnNode2)
if err := d.db.AddChannelEdge(edge); err != nil {
return nil, nil, err
}
edgePolicy := &channeldb.ChannelEdgePolicy{
SigBytes: testSig.Serialize(),
ChannelID: chanID.ToUint64(),
LastUpdate: time.Now(),
TimeLockDelta: 10,
MinHTLC: 1,
MaxHTLC: lnwire.NewMSatFromSatoshis(capacity),
FeeBaseMSat: 10,
FeeProportionalMillionths: 10000,
MessageFlags: 1,
ChannelFlags: 0,
edgePolicy := &channeldb.ChannelEdgePolicyWithNode{
ChannelEdgePolicy1: channeldb.ChannelEdgePolicy1{
SigBytes: testSig.Serialize(),
ChannelID: chanID.ToUint64(),
LastUpdate: time.Now(),
TimeLockDelta: 10,
MinHTLC: 1,
MaxHTLC: lnwire.NewMSatFromSatoshis(
capacity,
),
FeeBaseMSat: 10,
FeeProportionalMillionths: 10000,
MessageFlags: 1,
ChannelFlags: 0,
},
}

if err := d.db.UpdateEdgePolicy(edgePolicy); err != nil {
return nil, nil, err
}
edgePolicy = &channeldb.ChannelEdgePolicy{
SigBytes: testSig.Serialize(),
ChannelID: chanID.ToUint64(),
LastUpdate: time.Now(),
TimeLockDelta: 10,
MinHTLC: 1,
MaxHTLC: lnwire.NewMSatFromSatoshis(capacity),
FeeBaseMSat: 10,
FeeProportionalMillionths: 10000,
MessageFlags: 1,
ChannelFlags: 1,
edgePolicy = &channeldb.ChannelEdgePolicyWithNode{
ChannelEdgePolicy1: channeldb.ChannelEdgePolicy1{
SigBytes: testSig.Serialize(),
ChannelID: chanID.ToUint64(),
LastUpdate: time.Now(),
TimeLockDelta: 10,
MinHTLC: 1,
MaxHTLC: lnwire.NewMSatFromSatoshis(
capacity,
),
FeeBaseMSat: 10,
FeeProportionalMillionths: 10000,
MessageFlags: 1,
ChannelFlags: 1,
},
}
if err := d.db.UpdateEdgePolicy(edgePolicy); err != nil {
return nil, nil, err
Expand All @@ -267,13 +281,15 @@ func (d *databaseChannelGraph) addRandChannel(node1, node2 *btcec.PublicKey,
Capacity: capacity,
Peer: dbNode{
node: vertex1,
db: d.db.DB(),
},
},
&ChannelEdge{
ChanID: chanID,
Capacity: capacity,
Peer: dbNode{
node: vertex2,
db: d.db.DB(),
},
},
nil
Expand Down
2 changes: 1 addition & 1 deletion channeldb/channel_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func assertHasChanEntries(t *testing.T, c *channelCache, start, end uint64) {
// channelForInt generates a unique ChannelEdge given an integer.
func channelForInt(i uint64) ChannelEdge {
return ChannelEdge{
Info: &ChannelEdgeInfo{
Info: &ChannelEdgeInfo1{
ChannelID: i,
},
}
Expand Down
Loading
Loading