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
14 changes: 7 additions & 7 deletions graph/db/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func (c *ChannelGraph) FetchNodeFeatures(node route.Vertex) (
return c.graphCache.GetFeatures(node), nil
}

return c.db.FetchNodeFeatures(node)
return c.db.FetchNodeFeatures(lnwire.GossipVersion1, node)
}

// GraphSession will provide the call-back with access to a NodeTraverser
Expand Down Expand Up @@ -298,7 +298,7 @@ func (c *ChannelGraph) AddNode(ctx context.Context,
func (c *ChannelGraph) DeleteNode(ctx context.Context,
nodePub route.Vertex) error {

err := c.db.DeleteNode(ctx, nodePub)
err := c.db.DeleteNode(ctx, lnwire.GossipVersion1, nodePub)
if err != nil {
return err
}
Expand Down Expand Up @@ -607,7 +607,7 @@ func (c *ChannelGraph) UpdateEdgePolicy(ctx context.Context,
func (c *ChannelGraph) AddrsForNode(ctx context.Context,
nodePub *btcec.PublicKey) (bool, []net.Addr, error) {

return c.db.AddrsForNode(ctx, nodePub)
return c.db.AddrsForNode(ctx, lnwire.GossipVersion1, nodePub)
}

// ForEachSourceNodeChannel iterates through all channels of the source node.
Expand Down Expand Up @@ -646,7 +646,7 @@ func (c *ChannelGraph) ForEachNodeCacheable(ctx context.Context,
func (c *ChannelGraph) LookupAlias(ctx context.Context,
pub *btcec.PublicKey) (string, error) {

return c.db.LookupAlias(ctx, pub)
return c.db.LookupAlias(ctx, lnwire.GossipVersion1, pub)
}

// NodeUpdatesInHorizon returns all known lightning nodes with updates in the
Expand All @@ -661,7 +661,7 @@ func (c *ChannelGraph) NodeUpdatesInHorizon(startTime, endTime time.Time,
func (c *ChannelGraph) FetchNode(ctx context.Context,
nodePub route.Vertex) (*models.Node, error) {

return c.db.FetchNode(ctx, nodePub)
return c.db.FetchNode(ctx, lnwire.GossipVersion1, nodePub)
}

// HasV1Node determines if the graph has a vertex identified by the target node
Expand All @@ -677,7 +677,7 @@ func (c *ChannelGraph) HasV1Node(ctx context.Context,
func (c *ChannelGraph) HasNode(ctx context.Context, nodePub [33]byte) (bool,
error) {

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

// IsPublicNode determines whether the node is seen as public in the graph.
Expand Down Expand Up @@ -796,7 +796,7 @@ func (c *ChannelGraph) IsClosedScid(scid lnwire.ShortChannelID) (bool, error) {

// SourceNode returns the source node of the graph.
func (c *ChannelGraph) SourceNode(ctx context.Context) (*models.Node, error) {
return c.db.SourceNode(ctx)
return c.db.SourceNode(ctx, lnwire.GossipVersion1)
}

// SetSourceNode sets the source node within the graph database.
Expand Down
4 changes: 3 additions & 1 deletion graph/db/graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ func TestNodeInsertionAndDeletion(t *testing.T) {

// Check that the node's features are fetched correctly. This check
// will check the database directly.
features, err = graph.db.FetchNodeFeatures(node.PubKeyBytes)
features, err = graph.db.FetchNodeFeatures(
lnwire.GossipVersion1, node.PubKeyBytes,
)
require.NoError(t, err)
require.Equal(t, testFeatures, features)

Expand Down
27 changes: 19 additions & 8 deletions graph/db/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ type NodeTraverser interface {
// Store represents the main interface for the channel graph database for all
// channels and nodes gossiped via the V1 gossip protocol as defined in BOLT 7.
type Store interface { //nolint:interfacebloat
NodeTraverser
// ForEachNodeDirectedChannel calls the callback for every channel of
// the given node.
ForEachNodeDirectedChannel(nodePub route.Vertex,
cb func(channel *DirectedChannel) error, reset func()) error
Comment on lines +36 to +37
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess a version is added to that later PR because it involves channels?


// FetchNodeFeatures returns the features of the given node.
FetchNodeFeatures(v lnwire.GossipVersion,
nodePub route.Vertex) (*lnwire.FeatureVector, error)

// AddNode adds a vertex/node to the graph database. If the
// node is not in the database from before, this will add a new,
Expand All @@ -45,7 +52,7 @@ type Store interface { //nolint:interfacebloat
// 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.
AddrsForNode(ctx context.Context,
AddrsForNode(ctx context.Context, v lnwire.GossipVersion,
nodePub *btcec.PublicKey) (bool, []net.Addr, error)

// ForEachSourceNodeChannel iterates through all channels of the source
Expand Down Expand Up @@ -100,11 +107,13 @@ type Store interface { //nolint:interfacebloat

// LookupAlias attempts to return the alias as advertised by the target
// node.
LookupAlias(ctx context.Context, pub *btcec.PublicKey) (string, error)
LookupAlias(ctx context.Context, v lnwire.GossipVersion,
pub *btcec.PublicKey) (string, error)

// DeleteNode starts a new database transaction to remove a
// vertex/node from the database according to the node's public key.
DeleteNode(ctx context.Context, nodePub route.Vertex) error
DeleteNode(ctx context.Context, v lnwire.GossipVersion,
nodePub route.Vertex) error

// NodeUpdatesInHorizon returns all the known lightning node which have
// an update timestamp within the passed range. This method can be used
Expand All @@ -116,8 +125,8 @@ type Store interface { //nolint:interfacebloat
// FetchNode attempts to look up a target node by its identity
// public key. If the node isn't found in the database, then
// ErrGraphNodeNotFound is returned.
FetchNode(ctx context.Context, nodePub route.Vertex) (*models.Node,
error)
FetchNode(ctx context.Context, v lnwire.GossipVersion,
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
Expand All @@ -131,7 +140,8 @@ type Store interface { //nolint:interfacebloat

// HasNode determines if the graph has a vertex identified by
// the target node identity public key.
HasNode(ctx context.Context, nodePub [33]byte) (bool, error)
HasNode(ctx context.Context, v lnwire.GossipVersion,
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 Expand Up @@ -334,7 +344,8 @@ type Store interface { //nolint:interfacebloat
// treated as the center node within a star-graph. This method may be
// used to kick off a path finding algorithm in order to explore the
// reachability of another node based off the source node.
SourceNode(ctx context.Context) (*models.Node, error)
SourceNode(ctx context.Context, v lnwire.GossipVersion) (*models.Node,
error)

// SetSourceNode sets the source node within the graph database. The
// source node is to be used as the center of a star-graph within path
Expand Down
59 changes: 50 additions & 9 deletions graph/db/kv_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ var (
//
// maps: scid -> []byte{}
closedScidBucket = []byte("closed-scid")

// ErrVersionNotSupportedForKVDB is returned with KVStore queries are
// made using a gossip version other than V1.
ErrVersionNotSupportedForKVDB = errors.New("only gossip v1 is " +
"supported for kvdb graph store")
)

const (
Expand Down Expand Up @@ -376,15 +381,15 @@ func initKVStore(db kvdb.Backend) error {
// unknown to the graph DB or not.
//
// NOTE: this is part of the channeldb.AddrSource interface.
func (c *KVStore) AddrsForNode(ctx context.Context,
func (c *KVStore) AddrsForNode(ctx context.Context, v lnwire.GossipVersion,
nodePub *btcec.PublicKey) (bool, []net.Addr, error) {

pubKey, err := route.NewVertexFromBytes(nodePub.SerializeCompressed())
if err != nil {
return false, nil, err
}

node, err := c.FetchNode(ctx, pubKey)
node, err := c.FetchNode(ctx, v, pubKey)
// We don't consider it an error if the graph is unaware of the node.
switch {
case err != nil && !errors.Is(err, ErrGraphNodeNotFound):
Expand Down Expand Up @@ -666,8 +671,12 @@ func (c *KVStore) ForEachNodeDirectedChannel(nodePub route.Vertex,
// known for the node, an empty feature vector is returned.
//
// NOTE: this is part of the graphdb.NodeTraverser interface.
func (c *KVStore) FetchNodeFeatures(nodePub route.Vertex) (
*lnwire.FeatureVector, error) {
func (c *KVStore) FetchNodeFeatures(v lnwire.GossipVersion,
nodePub route.Vertex) (*lnwire.FeatureVector, error) {

if v != lnwire.GossipVersion1 {
return nil, ErrVersionNotSupportedForKVDB
}

return c.fetchNodeFeatures(nil, nodePub)
}
Expand Down Expand Up @@ -901,7 +910,13 @@ func (c *KVStore) ForEachNodeCacheable(_ context.Context,
// as the center node within a star-graph. This method may be used to kick off
// a path finding algorithm in order to explore the reachability of another
// node based off the source node.
func (c *KVStore) SourceNode(_ context.Context) (*models.Node, error) {
func (c *KVStore) SourceNode(_ context.Context,
v lnwire.GossipVersion) (*models.Node, error) {

if v != lnwire.GossipVersion1 {
return nil, ErrVersionNotSupportedForKVDB
}

return sourceNode(c.db)
}

Expand Down Expand Up @@ -955,6 +970,10 @@ func sourceNodeWithTx(nodes kvdb.RBucket) (*models.Node, error) {
func (c *KVStore) SetSourceNode(_ context.Context,
node *models.Node) error {

if node.Version != lnwire.GossipVersion1 {
return ErrVersionNotSupportedForKVDB
}

nodePubBytes := node.PubKeyBytes[:]

return kvdb.Update(c.db, func(tx kvdb.RwTx) error {
Expand Down Expand Up @@ -1021,9 +1040,13 @@ func addLightningNode(tx kvdb.RwTx, node *models.Node) error {

// LookupAlias attempts to return the alias as advertised by the target node.
// TODO(roasbeef): currently assumes that aliases are unique...
func (c *KVStore) LookupAlias(_ context.Context,
func (c *KVStore) LookupAlias(_ context.Context, v lnwire.GossipVersion,
pub *btcec.PublicKey) (string, error) {

if v != lnwire.GossipVersion1 {
return "", ErrVersionNotSupportedForKVDB
}

var alias string

err := kvdb.View(c.db, func(tx kvdb.RTx) error {
Expand Down Expand Up @@ -1060,9 +1083,13 @@ func (c *KVStore) LookupAlias(_ context.Context,

// DeleteNode starts a new database transaction to remove a vertex/node
// from the database according to the node's public key.
func (c *KVStore) DeleteNode(_ context.Context,
func (c *KVStore) DeleteNode(_ context.Context, v lnwire.GossipVersion,
nodePub route.Vertex) error {

if v != lnwire.GossipVersion1 {
return ErrVersionNotSupportedForKVDB
}

// TODO(roasbeef): ensure dangling edges are removed...
return kvdb.Update(c.db, func(tx kvdb.RwTx) error {
nodes := tx.ReadWriteBucket(nodeBucket)
Expand Down Expand Up @@ -3368,9 +3395,13 @@ func (c *KVStore) fetchNodeTx(tx kvdb.RTx, nodePub route.Vertex) (*models.Node,
// FetchNode attempts to look up a target node by its identity public
// key. If the node isn't found in the database, then ErrGraphNodeNotFound is
// returned.
func (c *KVStore) FetchNode(_ context.Context,
func (c *KVStore) FetchNode(_ context.Context, v lnwire.GossipVersion,
nodePub route.Vertex) (*models.Node, error) {

if v != lnwire.GossipVersion1 {
return nil, ErrVersionNotSupportedForKVDB
}

return c.fetchLightningNode(nil, nodePub)
}

Expand Down Expand Up @@ -3486,7 +3517,13 @@ func (c *KVStore) HasV1Node(_ context.Context,

// 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) {
func (c *KVStore) HasNode(_ context.Context, v lnwire.GossipVersion,
nodePub [33]byte) (bool, error) {

if v != lnwire.GossipVersion1 {
return false, ErrVersionNotSupportedForKVDB
}

var exists bool
err := kvdb.View(c.db, func(tx kvdb.RTx) error {
// First grab the nodes bucket which stores the mapping from
Expand Down Expand Up @@ -4366,6 +4403,10 @@ func (c *nodeTraverserSession) FetchNodeFeatures(nodePub route.Vertex) (
func putLightningNode(nodeBucket, aliasBucket, updateIndex kvdb.RwBucket,
node *models.Node) error {

if node.Version != lnwire.GossipVersion1 {
return ErrVersionNotSupportedForKVDB
}

var (
scratch [16]byte
b bytes.Buffer
Expand Down
Loading