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

multi: Add batched cfilter fetching messages #3211

Merged
merged 4 commits into from
May 13, 2024

Commits on May 13, 2024

  1. gcs: Add func to determine max cfilter size.

    This will be helpful in determining the max number of cfilters to return
    in a future batched getcfilter message.
    
    This will also nail down the maximum size of the filter based on the
    constants used throughout the project, such that if any of them changes,
    causing the max cfilter size to change, a test will break indicating the
    need to review any code paths that assume a max cfilter size.
    matheusd committed May 13, 2024
    Configuration menu
    Copy the full SHA
    7467ff5 View commit details
    Browse the repository at this point in the history
  2. wire: Add msgs to get batch of cfilters.

    This adds the getcfsv2 and cfiltersv2 messages. These messages are
    intended to allow nodes in the P2P network to request and receive a
    batch of version 2 committed filters that span multiple sequential
    blocks in a chain.
    
    These messages are intended to be used when syncing SPV clients, which
    require requesting all committed filters on the current main chain and
    currently use a large number of getcfilter/cfilter messages.
    
    One of the critical issues in the design for these messages is the
    MaxCFiltersV2PerBatch constant, which establishes an upper bound on the
    max number of cfilters requested and replied.  The current value of this
    constant was decided based on the max block size for all of the
    currently deployed networks, the max possible filter size for
    transactions in such a block and the max P2P message size.
    
    A runtime check is added to ensure any changes to the constants that
    were involved in deciding this number trigger a panic so that this bound
    is verified and, if needed, a new protocol version is introduced to
    update it.  This check is meant to guard against inadvertedly changing
    the assumptions that went into establishing this bound without reviewing
    it.
    matheusd committed May 13, 2024
    Configuration menu
    Copy the full SHA
    22a618b View commit details
    Browse the repository at this point in the history
  3. blockchain: Add function to locate multiple cfilters.

    This function will be used to reply to the recently introduced getcfsv2
    P2P message.
    
    The LocateCFiltersV2 function fetches a batch of cfilters from the
    database and encodes it in a wire.CFiltersV2 message, ready to be sent
    to remote peers.
    matheusd committed May 13, 2024
    Configuration menu
    Copy the full SHA
    5d4cfa2 View commit details
    Browse the repository at this point in the history
  4. multi: Respond to getcfsv2 message.

    This adds the appropriate processing to the peer and server structs to
    respond to the recently introduced getcfsv2 message.  It also bumps the
    peer and server max supported protocol versions to version 10
    (BatchedCFiltersV2Version).
    
    This message queries the chain for a batch of committed filters spanning
    a set of sequential blocks and will be used by SPV clients to fetch
    committed filters during their initial sync process.
    matheusd committed May 13, 2024
    Configuration menu
    Copy the full SHA
    5a28304 View commit details
    Browse the repository at this point in the history