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

Validate channel_update signatures without holding a graph lock #3310

Merged

Commits on Sep 11, 2024

  1. Refactor channel_update processing logic into local fns

    In the next commit we'll move to checking `channel_update`s in
    three steps - first we check if the `channel_update` is new and the
    latest for a channel, then we check the signature, and finally we
    update our local state. This allows us to avoid holding a lock on
    `NetworkGraph::channels` while validating the message signature.
    
    Here we do a quick prefactor to make that simpler - moving the
    validation logic of `channel_update` that we'll do in step one (and
    repeat in step three) into a local function. We also take this
    opportunity to do one static check unlocked which we had been doing
    while holding a `channel` lock.
    TheBlueMatt committed Sep 11, 2024
    Configuration menu
    Copy the full SHA
    0b7838b View commit details
    Browse the repository at this point in the history

Commits on Sep 23, 2024

  1. Validate channel_update signatures without holding a graph lock

    We often process many gossip messages in parallel across different
    peer connections, making the `NetworkGraph` mutexes fairly
    contention-sensitive (not to mention the potential that we want to
    send a payment and need to find a path to do so).
    
    Because we need to look up a node's public key to validate a
    signature on `channel_update` messages, we always need to take a
    `NetworkGraph::channels` lock before we can validate the message.
    
    For simplicity, and to avoid taking a lock twice, we'd always
    validated the `channel_update` signature while holding the same
    lock, but here we address the contention issues by doing a
    `channel_update` validation in three stages.
    
    First we take a read lock on `NetworkGraph::channels` and check if
    the `channel_update` is new, then release the lock and validate the
    message signature, and finally take a write lock, (re-check if the
    `channel_update` is new) and update the graph.
    TheBlueMatt committed Sep 23, 2024
    Configuration menu
    Copy the full SHA
    131849f View commit details
    Browse the repository at this point in the history