Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
3265d86
tools: use new golang 1.24 tool directive
ziggie1984 Sep 15, 2025
8dc48a9
tools: update golangci-lint to v2
ziggie1984 Sep 15, 2025
7b0b9b6
linter: remove unsupported linters from the codebase
ziggie1984 Sep 15, 2025
76d0250
CI: also use go tool for gosimports
ziggie1984 Sep 15, 2025
8f0a1dd
CI: remove unnecessary custom-gcl.yml file
ziggie1984 Sep 19, 2025
b977ba8
makefile: add linter config check
ziggie1984 Sep 19, 2025
80b98fd
lnwire: add NodeAnnouncement interface
ellemouton Sep 15, 2025
750ac7c
lnwire: define GossipVersion and GossipMessage
ellemouton Sep 15, 2025
5fc1e37
lnwire: let gossip messages implement GossipMessage
ellemouton Sep 15, 2025
e6e5f29
graph/db: use lnwire.GossipVersion instead of ProtocolVersion
ellemouton Sep 15, 2025
cbe5a5f
discovery: let reject cache use gossip version in key
ellemouton Sep 15, 2025
a0aad14
mulit: don't set customData on the lnrpc route level
ziggie1984 Sep 30, 2025
7f3a19c
paymentsdb: make verifyAttempt more robust
ziggie1984 Sep 30, 2025
b17a49f
lnwire: add onion message type
gijswijs May 14, 2025
08d9685
lnrpc: SendOnionMessage rpc endpoint
gijswijs May 22, 2025
6b16813
multi: endpoints for onion messages
gijswijs May 26, 2025
2bcf09e
chore: thread context through to SendCustomMessage
gijswijs Sep 25, 2025
6a1ea92
docs: update release notes for 0.21.0
gijswijs Oct 7, 2025
490587d
models: simplify models.Node
ellemouton Sep 4, 2025
7882b9b
multi: remove HaveNodeAnnouncement field from Node
ellemouton Sep 4, 2025
f2865f3
multi: add models.Node V1 constructor
ellemouton Sep 4, 2025
255471c
graph/db: simplify auth proof and edge info
ellemouton Sep 4, 2025
30e53b2
graph: remove DB interface
ellemouton Sep 16, 2025
6fcdbbb
graph/db: remove outdated comment
ellemouton Sep 15, 2025
1c3685f
graph/db: remove TestPopulateViaMigration
ellemouton Nov 6, 2025
323c336
multi: freeze graph SQL migration logic
ellemouton Nov 2, 2025
dc134c0
go.mod: replace local sqldb
ellemouton Nov 2, 2025
058e188
graph/db: freeze sql migration queries
ellemouton Nov 2, 2025
2c9b47f
docs: update release notes
ellemouton Nov 3, 2025
706b22a
Merge pull request #10338 from ellemouton/graphSQLMigFreeze
ellemouton Nov 9, 2025
00690cc
devrpc: fix comment
ellemouton Oct 29, 2025
c149db4
sqldb: add new gossip v2 columns to graph tables
ellemouton Nov 3, 2025
d54c54d
graph/db: rename V1Store to Store
ellemouton Nov 3, 2025
f733f6c
graph/db: add V2 Node constructor
ellemouton Oct 26, 2025
ab2cd65
sqldb: update node query for v2
ellemouton Oct 26, 2025
2cc17fd
graph/db: explicit redirect to Store
ellemouton Oct 26, 2025
2115261
graph/db: allow v2 nodes
ellemouton Oct 26, 2025
d714da5
graph/db: split HasNode into two methods
ellemouton Oct 26, 2025
1410779
graph/db: move gossip versions up one layer
ellemouton Oct 26, 2025
4bc6f92
graph/db: add helper variable for tests
ellemouton Oct 26, 2025
f114ba0
graph/db: introduce VersionedReader
ellemouton Oct 26, 2025
bd8f180
graph/db: let node helpers take version
ellemouton Oct 26, 2025
807a0ea
graph/db: test V2 node CRUD
ellemouton Oct 26, 2025
46ce8ab
graph/db: convert other node CRUD methods
ellemouton Oct 26, 2025
989e778
docs: update release notes
ellemouton Nov 3, 2025
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
2 changes: 1 addition & 1 deletion graph/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ func (b *Builder) assertNodeAnnFreshness(ctx context.Context, node route.Vertex,
// node announcements, we will ignore such nodes. If we do know about
// this node, check that this update brings info newer than what we
// already have.
lastUpdate, exists, err := b.cfg.Graph.HasNode(ctx, node)
lastUpdate, exists, err := b.cfg.Graph.HasV1Node(ctx, node)
if err != nil {
return fmt.Errorf("unable to query for the "+
"existence of node: %w", err)
Expand Down
13 changes: 11 additions & 2 deletions graph/db/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -664,10 +664,19 @@ func (c *ChannelGraph) FetchNode(ctx context.Context,
return c.db.FetchNode(ctx, nodePub)
}

// HasNode determines if the graph has a vertex identified by the target node.
func (c *ChannelGraph) HasNode(ctx context.Context,
// HasV1Node determines if the graph has a vertex identified by the target node
// in the V1 graph.
func (c *ChannelGraph) HasV1Node(ctx context.Context,
nodePub [33]byte) (time.Time, bool, error) {

return c.db.HasV1Node(ctx, nodePub)
}

// HasNode determines if the graph has a vertex identified by the target node
// in the V1 graph.
func (c *ChannelGraph) HasNode(ctx context.Context, nodePub [33]byte) (bool,
error) {

return c.db.HasNode(ctx, nodePub)
}

Expand Down
6 changes: 3 additions & 3 deletions graph/db/graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
dbNode, err := graph.FetchNode(ctx, testPub)
require.NoError(t, err, "unable to locate node")

_, exists, err := graph.HasNode(ctx, dbNode.PubKeyBytes)
exists, err := graph.HasNode(ctx, dbNode.PubKeyBytes)
require.NoError(t, err)
require.True(t, exists)

Expand Down Expand Up @@ -309,7 +309,7 @@ func TestPartialNode(t *testing.T) {
dbNode2, err := graph.FetchNode(ctx, pubKey2)
require.NoError(t, err)

_, exists, err := graph.HasNode(ctx, dbNode1.PubKeyBytes)
exists, err := graph.HasNode(ctx, dbNode1.PubKeyBytes)
require.NoError(t, err)
require.True(t, exists)

Expand All @@ -318,7 +318,7 @@ func TestPartialNode(t *testing.T) {
expectedNode1 := models.NewV1ShellNode(pubKey1)
compareNodes(t, expectedNode1, dbNode1)

_, exists, err = graph.HasNode(ctx, dbNode2.PubKeyBytes)
exists, err = graph.HasNode(ctx, dbNode2.PubKeyBytes)
require.NoError(t, err)
require.True(t, exists)

Expand Down
17 changes: 12 additions & 5 deletions graph/db/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,19 @@ type Store interface { //nolint:interfacebloat
FetchNode(ctx context.Context, nodePub route.Vertex) (*models.Node,
error)

// HasV1Node determines if the graph has a vertex identified by
// the target node identity public key in the V1 graph. If the node
// exists in the database, a timestamp of when the data for the node
// was lasted updated is returned along with a true boolean. Otherwise,
// an empty time.Time is returned with a false boolean.
// This is specific to the V1 graph since only V1 node announcements
// use timestamps for their latest update timestamp.
HasV1Node(ctx context.Context, nodePub [33]byte) (time.Time, bool,
error)

// HasNode determines if the graph has a vertex identified by
// the target node identity public key. If the node exists in the
// database, a timestamp of when the data for the node was lasted
// updated is returned along with a true boolean. Otherwise, an empty
// time.Time is returned with a false boolean.
HasNode(ctx context.Context, nodePub [33]byte) (time.Time, bool, error)
// the target node identity public key.
HasNode(ctx context.Context, nodePub [33]byte) (bool, error)

// IsPublicNode is a helper method that determines whether the node with
// the given public key is seen as a public node in the graph from the
Expand Down
37 changes: 35 additions & 2 deletions graph/db/kv_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -3431,12 +3431,12 @@ func (c *KVStore) fetchLightningNode(tx kvdb.RTx,
return node, nil
}

// HasLightningNode determines if the graph has a vertex identified by the
// HasV1Node determines if the graph has a vertex identified by the
// target node identity public key. If the node exists in the database, a
// timestamp of when the data for the node was lasted updated is returned along
// with a true boolean. Otherwise, an empty time.Time is returned with a false
// boolean.
func (c *KVStore) HasNode(_ context.Context,
func (c *KVStore) HasV1Node(_ context.Context,
nodePub [33]byte) (time.Time, bool, error) {

var (
Expand Down Expand Up @@ -3484,6 +3484,39 @@ func (c *KVStore) HasNode(_ context.Context,
return updateTime, exists, nil
}

// HasNode determines if the graph has a vertex identified by the target node
// identity public key.
func (c *KVStore) HasNode(_ context.Context, nodePub [33]byte) (bool, error) {
var exists bool
err := kvdb.View(c.db, func(tx kvdb.RTx) error {
// First grab the nodes bucket which stores the mapping from
// pubKey to node information.
nodes := tx.ReadBucket(nodeBucket)
if nodes == nil {
return ErrGraphNotFound
}

// If a key for this serialized public key isn't found, we can
// exit early.
nodeBytes := nodes.Get(nodePub[:])
if nodeBytes == nil {
exists = false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: exists is already false

return nil
}

exists = true

return nil
}, func() {
exists = false
})
if err != nil {
return exists, err
}

return exists, nil
}

// nodeTraversal is used to traverse all channels of a node given by its
// public key and passes channel information into the specified callback.
//
Expand Down
37 changes: 35 additions & 2 deletions graph/db/sql_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,14 @@ func (s *SQLStore) FetchNode(ctx context.Context,
return node, nil
}

// HasNode determines if the graph has a vertex identified by the
// HasV1Node determines if the graph has a vertex identified by the
// target node identity public key. If the node exists in the database, a
// timestamp of when the data for the node was lasted updated is returned along
// with a true boolean. Otherwise, an empty time.Time is returned with a false
// boolean.
//
// NOTE: part of the Store interface.
func (s *SQLStore) HasNode(ctx context.Context,
func (s *SQLStore) HasV1Node(ctx context.Context,
pubKey [33]byte) (time.Time, bool, error) {

var (
Expand Down Expand Up @@ -325,6 +325,39 @@ func (s *SQLStore) HasNode(ctx context.Context,
return lastUpdate, exists, nil
}

// HasNode determines if the graph has a vertex identified by the
// target node identity public key.
//
// NOTE: part of the Store interface.
func (s *SQLStore) HasNode(ctx context.Context, pubKey [33]byte) (bool, error) {
var (
v = lnwire.GossipVersion1
exists bool
)
err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
_, err := db.GetNodeByPubKey(
ctx, sqlc.GetNodeByPubKeyParams{
Version: int16(v),
PubKey: pubKey[:],
},
)
if errors.Is(err, sql.ErrNoRows) {
return nil
} else if err != nil {
return fmt.Errorf("unable to fetch node: %w", err)
}

exists = true

return nil
}, sqldb.NoOpReset)
if err != nil {
return false, fmt.Errorf("unable to fetch node: %w", err)
}

return exists, nil
}

// AddrsForNode returns all known addresses for the target node public key
// that the graph DB is aware of. The returned boolean indicates if the
// given node is unknown to the graph DB or not.
Expand Down
8 changes: 4 additions & 4 deletions routing/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2717,11 +2717,11 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
copy(pub2[:], priv2.PubKey().SerializeCompressed())

// The two nodes we are about to add should not exist yet.
_, exists1, err := ctx.graph.HasNode(ctxb, pub1)
exists1, err := ctx.graph.HasNode(ctxb, pub1)
require.NoError(t, err, "unable to query graph")
require.False(t, exists1)

_, exists2, err := ctx.graph.HasNode(ctxb, pub2)
exists2, err := ctx.graph.HasNode(ctxb, pub2)
require.NoError(t, err, "unable to query graph")
require.False(t, exists2)

Expand Down Expand Up @@ -2778,11 +2778,11 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {

// After adding the edge between the two previously unknown nodes, they
// should have been added to the graph.
_, exists1, err = ctx.graph.HasNode(ctxb, pub1)
exists1, err = ctx.graph.HasNode(ctxb, pub1)
require.NoError(t, err, "unable to query graph")
require.True(t, exists1)

_, exists2, err = ctx.graph.HasNode(ctxb, pub2)
exists2, err = ctx.graph.HasNode(ctxb, pub2)
require.NoError(t, err, "unable to query graph")
require.True(t, exists2)

Expand Down
2 changes: 1 addition & 1 deletion rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1793,7 +1793,7 @@ func (r *rpcServer) VerifyMessage(ctx context.Context,
//
// TODO(phlip9): Require valid nodes to have capital in active channels.
graph := r.server.graphDB
_, active, err := graph.HasNode(ctx, pub)
active, err := graph.HasNode(ctx, pub)
if err != nil {
return nil, fmt.Errorf("failed to query graph: %w", err)
}
Expand Down