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

netsync: Rework inventory announcement handling. #2548

Merged
merged 2 commits into from
Jan 15, 2021

Commits on Jan 15, 2021

  1. blockchain: Remove error from LatestBlockLocator.

    This removes the error return from the LatestBlockLocator function since
    it can never fail and ends up causing unneeded error checking.
    davecgh committed Jan 15, 2021
    Configuration menu
    Copy the full SHA
    1937ba2 View commit details
    Browse the repository at this point in the history
  2. netsync: Rework inventory announcement handling.

    This modifies the way inventory announcements are handled to improve
    efficiency and readability.
    
    Specifically, it switches to a more explicit approach that handles the
    specific recognized types (blocks and transactions) independently and
    now determines if they are needed with unique logic for each type as
    opposed to the more generic inventory-only based approach.
    
    Next, and probably the most important change overall, is that recently
    confirmed transactions are now tracked by the server and the logic which
    determines if a transaction is needed now makes use of those tracked
    transactions as opposed to the previous rather expensive utxo-based
    query approach.
    
    The reasoning for this change is that the only time honest nodes notify
    others about transactions are when they view those transactions as
    unconfirmed and they consider themselves to be current.  In practice
    this means the only duplicate announcements are for unconfirmed and
    recently confirmed transactions.  In the case of malicious nodes, the
    transactions are rejected (either the transactions are actually invalid
    or they are old transactions that were valid in the past but will now
    fail due to trying to spend outputs they already spent).
    
    So, given the above discussion, there are 3 cases to handle:
    
    1) Duplicate announcements for unconfirmed transactions
    2) Duplicate announcements for txns that have already been rejected
    3) Duplicate announcements for recently-confirmed transactions
    
    For the first case, the duplicate request is filtered by the mempool
    since it already knows the unconfirmed transaction.  For the second
    case, rejected transactions are tracked separately and filtered.  Thus,
    only the third case of recently confirmed transactions remains.
    
    Finally, the last block is now tracked by the hash instead of an index
    into the index which allows the relevant updates to take place after the
    main loop versus inside of it conditionally.
    davecgh committed Jan 15, 2021
    Configuration menu
    Copy the full SHA
    c93e1a0 View commit details
    Browse the repository at this point in the history