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: Introduce AssumeValid. #2839

Merged
merged 8 commits into from Dec 11, 2021
Merged

multi: Introduce AssumeValid. #2839

merged 8 commits into from Dec 11, 2021

Commits on Dec 5, 2021

  1. chaincfg: Add AssumeValid param.

    This introduces an AssumeValid parameter that is the hash of a block
    that has been externally verified to be valid.  In a subsequent commit,
    it will be used to allow several validation checks to be skipped for
    blocks that are both an ancestor of the assumed valid block and an
    ancestor of the best header.
    
    Note that the AssumeValid block hash that is specified for mainnet and
    testnet is for the same block that was used for MinKnownChainWork.
    Using the same block for both of these slightly simplifies the process
    for external verification of the values when they are updated
    periodically with new releases.
    rstaudt2 committed Dec 5, 2021
    Configuration menu
    Copy the full SHA
    cf002c4 View commit details
    Browse the repository at this point in the history
  2. multi: Add assumeValid to BlockChain.

    This adds an assumeValid field to BlockChain and sets it based on the
    AssumeValid chain parameter.
    rstaudt2 committed Dec 5, 2021
    Configuration menu
    Copy the full SHA
    3801b11 View commit details
    Browse the repository at this point in the history
  3. blockchain: Track assumed valid node.

    This adds tracking of the assumed valid node to BlockChain.  The assumed
    valid node will be used in place of checkpoints to set the BFFastAdd
    flag in a subsequent commit.
    rstaudt2 committed Dec 5, 2021
    Configuration menu
    Copy the full SHA
    7037dee View commit details
    Browse the repository at this point in the history
  4. blockchain: Set BFFastAdd based on assume valid.

    This updates BlockChain to set the BFFastAdd flag if a block is both an
    ancestor of the assumed valid block and an ancestor of the best header.
    
    A helper function isAssumeValidAncestor is introduced that determines
    whether the provided node is both an ancestor of the assumed valid node
    and an ancestor of the best header.  False is returned when the assume
    valid node has not been discovered or when assume valid is disabled.
    
    The assumed valid node is clamped back as needed to ensure that it is at
    least 2 weeks worth of blocks behind the best header.  This protects
    against malicious actors trying to play games by tricking users into
    using an assumed valid hash near the tip.
    rstaudt2 committed Dec 5, 2021
    Configuration menu
    Copy the full SHA
    a35ef9a View commit details
    Browse the repository at this point in the history
  5. blockchain: Assume valid skip script validation.

    This updates block validation to not run scripts if a block is both an
    ancestor of the assumed valid block and an ancestor of the best header.
    rstaudt2 committed Dec 5, 2021
    Configuration menu
    Copy the full SHA
    628cd34 View commit details
    Browse the repository at this point in the history
  6. blockchain: Bulk import skip script validation.

    This updates block validation to not run scripts if bulk import mode is
    enabled.  Bulk import mode is only enabled when importing blocks that
    are already known to be valid.
    rstaudt2 committed Dec 5, 2021
    Configuration menu
    Copy the full SHA
    e09b817 View commit details
    Browse the repository at this point in the history
  7. blockchain: Add AssumeValid tests.

    This adds tests that validate that it is correctly determined whether or
    not a node is an ancestor of an assumed valid node under a variety of
    conditions.
    rstaudt2 committed Dec 5, 2021
    Configuration menu
    Copy the full SHA
    f67415c View commit details
    Browse the repository at this point in the history
  8. multi: Add assumevalid config option.

    This adds an assumevalid config option which allows for specifying a
    hash of an assumed valid block or disabling assume valid.
    
    The usage is as follows:
    
    * (flag not specified): defaults to the hard-coded value in source
    * --assumevalid=0: disable AssumeValid
    * --assumevalid=[blockhash]: set AssumeValid to the specified block hash
    rstaudt2 committed Dec 5, 2021
    Configuration menu
    Copy the full SHA
    288b106 View commit details
    Browse the repository at this point in the history