Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
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
11 changes: 9 additions & 2 deletions discovery/chan_series.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/lightningnetwork/lnd/fn/v2"
graphdb "github.com/lightningnetwork/lnd/graph/db"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/netann"
Expand Down Expand Up @@ -115,7 +116,10 @@ func (c *ChanSeries) UpdatesInHorizon(chain chainhash.Hash,
// First, we'll query for all the set of channels that have an
// update that falls within the specified horizon.
chansInHorizon := c.graph.ChanUpdatesInHorizon(
context.TODO(), startTime, endTime,
context.TODO(), graphdb.ChanUpdateRange{
StartTime: fn.Some(startTime),
EndTime: fn.Some(endTime),
},
)

for channel, err := range chansInHorizon {
Expand Down Expand Up @@ -181,7 +185,10 @@ func (c *ChanSeries) UpdatesInHorizon(chain chainhash.Hash,
// update within the horizon as well. We send these second to
// ensure that they follow any active channels they have.
nodeAnnsInHorizon := c.graph.NodeUpdatesInHorizon(
context.TODO(), startTime, endTime,
context.TODO(), graphdb.NodeUpdateRange{
StartTime: fn.Some(startTime),
EndTime: fn.Some(endTime),
},
graphdb.WithIterPublicNodesOnly(),
)
for nodeAnn, err := range nodeAnnsInHorizon {
Expand Down
9 changes: 6 additions & 3 deletions discovery/gossiper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2187,9 +2187,12 @@ func (d *AuthenticatedGossiper) addNode(ctx context.Context,
err)
}

return d.cfg.Graph.AddNode(
ctx, models.NodeFromWireAnnouncement(msg), op...,
)
node, err := models.NodeFromWireAnnouncement(msg)
if err != nil {
return err
}

return d.cfg.Graph.AddNode(ctx, node, op...)
}

// isPremature decides whether a given network message has a block height+delta
Expand Down
11 changes: 11 additions & 0 deletions docs/release-notes/release-notes-0.21.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,17 @@
[4](https://github.com/lightningnetwork/lnd/pull/10542),
[5](https://github.com/lightningnetwork/lnd/pull/10572),
[6](https://github.com/lightningnetwork/lnd/pull/10582).
* Make the [graph `Store` interface
cross-version](https://github.com/lightningnetwork/lnd/pull/10656) so that
query methods (`ForEachNode`, `ForEachChannel`, `NodeUpdatesInHorizon`,
`ChanUpdatesInHorizon`, `FilterKnownChanIDs`) work across gossip v1 and v2.
Add `PreferHighest` fetch helpers and `GetVersions` queries so callers can
retrieve channels without knowing which gossip version announced them.
* Add [v2 model and store
support](https://github.com/lightningnetwork/lnd/pull/10657) to the graph
database: wire conversion helpers for node announcements, channel auth
proofs, edge info, and edge policies; `VersionedGraph` zombie wrappers;
SQL queries for v2 node traversal; and v3-only onion address filtering.
* Updated waiting proof persistence for gossip upgrades by introducing typed
waiting proof keys and payloads, with a DB migration to rewrite legacy
waiting proof records to the new key/value format
Expand Down
7 changes: 6 additions & 1 deletion graph/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/batch"
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/fn/v2"
graphdb "github.com/lightningnetwork/lnd/graph/db"
"github.com/lightningnetwork/lnd/graph/db/models"
"github.com/lightningnetwork/lnd/lnutils"
Expand Down Expand Up @@ -648,7 +649,11 @@ func (b *Builder) pruneZombieChans() error {
startTime := time.Unix(0, 0)
endTime := time.Now().Add(-1 * chanExpiry)
oldEdgesIter := b.cfg.Graph.ChanUpdatesInHorizon(
context.TODO(), startTime, endTime,
context.TODO(), lnwire.GossipVersion1,
graphdb.ChanUpdateRange{
StartTime: fn.Some(startTime),
EndTime: fn.Some(endTime),
},
)

for u, err := range oldEdgesIter {
Expand Down
33 changes: 22 additions & 11 deletions graph/db/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ func TestPopulateDBs(t *testing.T) {
numPolicies = 0
)
err := graph.ForEachChannel(
ctx, lnwire.GossipVersion1,
ctx,
func(info *models.ChannelEdgeInfo, policy,
policy2 *models.ChannelEdgePolicy) error {

Expand Down Expand Up @@ -500,7 +500,7 @@ func syncGraph(t *testing.T, src, dest *ChannelGraph) {
}

var wgChans sync.WaitGroup
err = src.ForEachChannel(ctx, lnwire.GossipVersion1,
err = src.ForEachChannel(ctx,
func(info *models.ChannelEdgeInfo,
policy1, policy2 *models.ChannelEdgePolicy) error {

Expand Down Expand Up @@ -624,7 +624,7 @@ func BenchmarkGraphReadMethods(b *testing.B) {
name: "ForEachNode",
fn: func(b testing.TB, store Store) {
err := store.ForEachNode(
ctx, lnwire.GossipVersion1,
ctx,
func(_ *models.Node) error {
// Increment the counter to
// ensure the callback is doing
Expand All @@ -640,12 +640,11 @@ func BenchmarkGraphReadMethods(b *testing.B) {
{
name: "ForEachChannel",
fn: func(b testing.TB, store Store) {
//nolint:ll
err := store.ForEachChannel(
ctx, lnwire.GossipVersion1,
err := store.ForEachChannel(ctx,
func(_ *models.ChannelEdgeInfo,
_,
_ *models.ChannelEdgePolicy,
_ *models.ChannelEdgePolicy) error {
) error {

// Increment the counter to
// ensure the callback is doing
Expand All @@ -662,7 +661,13 @@ func BenchmarkGraphReadMethods(b *testing.B) {
name: "NodeUpdatesInHorizon",
fn: func(b testing.TB, store Store) {
iter := store.NodeUpdatesInHorizon(
ctx, time.Unix(0, 0), time.Now(),
ctx, lnwire.GossipVersion1,
NodeUpdateRange{
StartTime: fn.Some(
time.Unix(0, 0),
),
EndTime: fn.Some(time.Now()),
},
)
_, err := fn.CollectErr(iter)
require.NoError(b, err)
Expand Down Expand Up @@ -713,7 +718,13 @@ func BenchmarkGraphReadMethods(b *testing.B) {
name: "ChanUpdatesInHorizon",
fn: func(b testing.TB, store Store) {
iter := store.ChanUpdatesInHorizon(
ctx, time.Unix(0, 0), time.Now(),
ctx, lnwire.GossipVersion1,
ChanUpdateRange{
StartTime: fn.Some(
time.Unix(0, 0),
),
EndTime: fn.Some(time.Now()),
},
)
_, err := fn.CollectErr(iter)
require.NoError(b, err)
Expand Down Expand Up @@ -817,7 +828,7 @@ func BenchmarkFindOptimalSQLQueryConfig(b *testing.B) {
)

err := store.ForEachNode(
ctx, lnwire.GossipVersion1,
ctx,
func(_ *models.Node) error {
numNodes++

Expand All @@ -828,7 +839,7 @@ func BenchmarkFindOptimalSQLQueryConfig(b *testing.B) {

//nolint:ll
err = store.ForEachChannel(
ctx, lnwire.GossipVersion1,
ctx,
func(_ *models.ChannelEdgeInfo,
_,
_ *models.ChannelEdgePolicy) error {
Expand Down
Loading
Loading