Skip to content

Don't serve channels in the range reply without a valid ChanUpdate. #9041

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
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
18 changes: 9 additions & 9 deletions channeldb/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -2335,15 +2335,6 @@ func (c *ChannelGraph) FilterChannelRange(startHeight,
cid, time.Time{}, time.Time{},
)

if !withTimestamps {
Copy link
Collaborator

Choose a reason for hiding this comment

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

don't think we should encode timestamps if we've decided to not send them

Copy link
Collaborator Author

@ziggie1984 ziggie1984 Aug 28, 2024

Choose a reason for hiding this comment

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

we are not encoding them here, we will not include them in the msg if timestamp is not selected, the above is just the filtering logic.

This is where we decide whether we include the timestamp:

lnd/discovery/syncer.go

Lines 1137 to 1157 in 5c3a8e9

var timestamps lnwire.Timestamps
if withTimestamps {
timestamps = make(lnwire.Timestamps, len(channelChunk))
}
scids := make([]lnwire.ShortChannelID, len(channelChunk))
for i, info := range channelChunk {
scids[i] = info.ShortChannelID
if !withTimestamps {
continue
}
timestamps[i].Timestamp1 = uint32(
info.Node1UpdateTimestamp.Unix(),
)
timestamps[i].Timestamp2 = uint32(
info.Node2UpdateTimestamp.Unix(),
)
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

ah right

channelsPerBlock[cid.BlockHeight] = append(
channelsPerBlock[cid.BlockHeight],
chanInfo,
)

continue
}

node1Key, node2Key := computeEdgePolicyKeys(&edgeInfo)

rawPolicy := edges.Get(node1Key)
Expand Down Expand Up @@ -2376,6 +2367,15 @@ func (c *ChannelGraph) FilterChannelRange(startHeight,
chanInfo.Node2UpdateTimestamp = edge.LastUpdate
}

//nolint:lll
// We don't serve Channels we havn't seen any ChanUpdate
// msg from.
Copy link
Collaborator

Choose a reason for hiding this comment

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

drive-by style nit: remove nolint and...

t1 := chanInfo.Node1UpdateTimestamp
t2 := chanInfo.Node2UpdateTimestamp
if t1.Equal(time.Unix(0, 0)) && t2.Equal(time.Unix(0, 0)) {
      continue
}

if chanInfo.Node1UpdateTimestamp.Equal(time.Unix(0, 0)) &&
chanInfo.Node2UpdateTimestamp.Equal(time.Unix(0, 0)) {

continue
}

channelsPerBlock[cid.BlockHeight] = append(
channelsPerBlock[cid.BlockHeight], chanInfo,
)
Expand Down
Loading