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

main, rpcclient, integration: add rpccalls for invalidate and reconsiderblock #2183

Commits on Apr 22, 2024

  1. blockchain, workmath: refactor functions to workmath package

    Some of the functions in difficulty.go are not dependent on any external
    functions and they are needed to introduce testing code for the
    invalidateblock and reconsiderblock methods that are to be added on in
    later commits. Having the workmath package let's us reuse the code and
    avoid dependency cycles.
    
    The existing functions that were exported already (HashToBig,
    CompactToBig, BigToCompact, CalcWork) are still kept in difficulty.go
    to avoid breaking external code that depends on those exported
    functions.
    kcalvinalvin committed Apr 22, 2024
    Configuration menu
    Copy the full SHA
    597b68c View commit details
    Browse the repository at this point in the history
  2. fullblocktests, testhelper: refactor out spendableOut

    spendableOut and the functions related to it are is moved to package
    testhelper and are exported.  This is done to make the code reusable
    without introducing an import cycle when the testing code for
    invalidateblock and reconsiderblock are added in follow up commits.
    kcalvinalvin committed Apr 22, 2024
    Configuration menu
    Copy the full SHA
    337d7f6 View commit details
    Browse the repository at this point in the history
  3. fullblocktests, testhelper: move solveBlock to testhelper

    solveBlock is moved to testhelper and is exported.  This is done so that
    the code can be reused without introducing import cycles.  The testing
    code to be added in alter commits for invalidateblock and reconsider
    block will use SolveBlock.
    kcalvinalvin committed Apr 22, 2024
    Configuration menu
    Copy the full SHA
    d4644df View commit details
    Browse the repository at this point in the history
  4. fullblocktests, testhelper: move opTrueScript and lowFee to testhelper

    The variables are moved to testhelper so that they can be reused in the
    blockchain package without introducing an import cycle.  The testing
    code for invalidateblock and reconsiderblock that will be added in later
    commits will be using these variables.
    kcalvinalvin committed Apr 22, 2024
    Configuration menu
    Copy the full SHA
    62790ac View commit details
    Browse the repository at this point in the history
  5. fullblocktests, testhelper: move uniqueOpReturnScript to testhelper

    uniqueOpReturnScript is moved to testhelper and is exported so that the
    code and be reused in package blockchain without introducing import
    cycles.  The test code for invalidateblock and reconsiderblock that are
    gonna be added in later commits uses the functions.
    kcalvinalvin committed Apr 22, 2024
    Configuration menu
    Copy the full SHA
    9093243 View commit details
    Browse the repository at this point in the history
  6. fullblocktests, testhelper: move standardCoinbaseScript to testhelper

    standardCoinbaseScript is moved to testhelper and is exported.  This
    allows test code in package blockchain to reuse the code without
    introducing an import cycle.  This code is used in the testing code
    for invalidateblock and reconsiderblock that's added in the later
    commits.
    kcalvinalvin committed Apr 22, 2024
    Configuration menu
    Copy the full SHA
    59c7d10 View commit details
    Browse the repository at this point in the history
  7. fullblocktests, testhelper: move createCoinbaseTx to testhelper

    createCoinbaseTx's code is refactored out and placed in testhelper
    package and is exported so that callers in package blockchain can reuse
    the code without introducing import cycles.  The test code for
    invalidateblock and reconsiderblock that'll be added in later commits
    make use of this code.
    kcalvinalvin committed Apr 22, 2024
    Configuration menu
    Copy the full SHA
    8ab27b9 View commit details
    Browse the repository at this point in the history
  8. fullblocktests, testhelper: move createSpendTx to testhelper

    createSpendTx is moved to testhelper so that the function can be used
    for callers in package blockchain without introducing import cycles.
    The test code for invalidateblock and reconsiderblock that are going to
    be added in later commits make use of this code.
    kcalvinalvin committed Apr 22, 2024
    Configuration menu
    Copy the full SHA
    5df1437 View commit details
    Browse the repository at this point in the history
  9. blockchain: add block generating functions in test code

    The block generating functions here allow for a test to create mock
    blocks.  This is useful for testing invalidateblock and reconsiderblock
    methods on blockchain that will be added in later commits.
    kcalvinalvin committed Apr 22, 2024
    Configuration menu
    Copy the full SHA
    ea39fe0 View commit details
    Browse the repository at this point in the history

Commits on Apr 30, 2024

  1. blockchain: Add InvalidateBlock() method to BlockChain

    InvalidateBlock() invalidates a given block and marks all its
    descendents as invalid as well. The active chain tip changes if the
    invalidated block is part of the best chain.
    kcalvinalvin committed Apr 30, 2024
    Configuration menu
    Copy the full SHA
    635ae68 View commit details
    Browse the repository at this point in the history
  2. blockchain: Refactor reorganizeChain to exclude verification

    reorganizeChain() used to handle the following:
    1: That the blocknodes being disconnected/connected indeed to connect
       properly without errors.
    2: Perform the actual disconnect/connect of the blocknodes.
    
    The functionality of 1, the validation that the disconnects/connects can
    happen without errors are now refactored out into
    verifyReorganizationValidity.
    
    This is an effort made so that ReconsiderBlock() can call
    verifyReorganizationValidity and set the block status of the
    reconsidered chain and return nil even when an error returns as it's ok
    to get an error when reconsidering an invalid branch.
    kcalvinalvin committed Apr 30, 2024
    Configuration menu
    Copy the full SHA
    c14546b View commit details
    Browse the repository at this point in the history
  3. blockchain: Add ReconsiderBlock to BlockChain

    ReconsiderBlock reconsiders the validity of the block for the passed
    in blockhash. The behavior of the function mimics that of Bitcoin Core.
    
    The invalid status of the block nodes are reset and if the chaintip that
    is being reconsidered has more cumulative work, then we'll validate the
    blocks and reorganize to it. If the cumulative work is lesser than the
    current active chain tip, then nothing else will be done.
    kcalvinalvin committed Apr 30, 2024
    Configuration menu
    Copy the full SHA
    7c04bd8 View commit details
    Browse the repository at this point in the history

Commits on May 5, 2024

  1. main: Add invalidateblock and reconsiderblock rpc commands

    The rpc calls and the rpchelp is added for the invalidateblock
    and reconsiderblock methods on BlockChain.
    kcalvinalvin committed May 5, 2024
    Configuration menu
    Copy the full SHA
    794c334 View commit details
    Browse the repository at this point in the history
  2. rpcclient, integration: Add invalidateblock and reconsiderblock

    invalidateblock and reconsiderblock are added to the rpcclient package
    and an integration test is added to test the added functions.
    kcalvinalvin committed May 5, 2024
    Configuration menu
    Copy the full SHA
    5fbd6e6 View commit details
    Browse the repository at this point in the history