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

chaincfg+blockchain: abstract/refactor BIP 9 version bits implementation to work w/ BIP 8 block heights #1700

Merged
merged 8 commits into from Jan 26, 2022

Commits on Jan 25, 2022

  1. chaincfg: create new abstract deployment starter/ender interfaces

    In this commit, we create a series of new interfaces that'll allow us to
    abstract "when" exactly a deployment starts and ends. As is, all
    deployments start/end based on a unix timestamp, which is compared
    against the MTP of a given block to determine if a new deployment has
    started or ended. This works fine for BIP 9 which uses time based
    timeouts, but not so much for BIP 8. In order to prep a future refactor
    that allows our version bits implementation to support both time and
    block based start/end times, this new abstraction has been introduced.
    Roasbeef committed Jan 25, 2022
    Copy the full SHA
    dc4dc15 View commit details
    Browse the repository at this point in the history
  2. chaincfg: use DeploymentStarter/DeploymentEnder instead of start/end …

    …times
    
    In this commit, we utilize the recently added ConsensusDeploymentStarter
    and ConsensusDeploymentEnder interfaces. Concrete implementations of
    this interface based on the median time past comparison are used now in
    the ConsensusDeployment struct instead of hard coded start/end times.
    
    Along the way, we had to switch to using the "zero time": time.Time{},
    in place of 0 and math.MaxInt64 as comparison (After/Before) seems to be
    broken in the Go stdlib for times very far in the future. It appears Go
    isn't ready to handle the heat death of the universe.
    Roasbeef committed Jan 25, 2022
    Copy the full SHA
    2b6370d View commit details
    Browse the repository at this point in the history
  3. blockchain: update version bits logic to use HasStarted/HasEnded for …

    …deployments
    
    In this commit, we update our version bits logic to use the newly added
    HasStarted and HasEnded methods for consensus deployments. Along the
    way, wee modify the thresholdConditionChecker` interface to be based off
    the new chaincfg interfaces. In addition, we add a new method
    `PastMedianTime`, in order to allow the chain itself to be used as a
    `chaincfg.BlockClock`.
    
    This serves to make the logic more generic in order to support both
    block height and time based soft fork timeouts.
    Roasbeef committed Jan 25, 2022
    Copy the full SHA
    298d616 View commit details
    Browse the repository at this point in the history
  4. Copy the full SHA
    0556c70 View commit details
    Browse the repository at this point in the history
  5. chainparams: add new DeploymentTestDummyMinActivation

    In this commit, we add a new "dummy" deployment that adds the new params
    used to activate taproot. We chose to add a new deployment as unlike the
    bitcoind codebase, we don't currently "bury" soft forks that have
    happened in the past (hard code an activation height).
    
    The old taproot deployment has been removed as with the way the array
    works, a deployment needs to be defined for _all_ networks.
    Roasbeef committed Jan 25, 2022
    Copy the full SHA
    38737a8 View commit details
    Browse the repository at this point in the history
  6. blockchain+integration: add support for min activation height and cus…

    …tom thresholds
    
    In this commit, we extend the existing version bits state machine to add
    support for the new minimum activation height and custom block threshold
    for activation. We then extend the existing BIP 9 tests (tho this isn't
    really BIP 9 anymore...) to exercise the new min activation height
    logic.
    Roasbeef committed Jan 25, 2022
    Copy the full SHA
    c6b66ee View commit details
    Browse the repository at this point in the history
  7. blockchain: refactor new thresholdState method, test BIP9 transitions

    In this commit, we extract the BIP 9 state transition logic from the
    thresholdState method into a new thresholdStateTransition function that
    allows us to test all the defined state transitions, including the
    modified "speedy trial" logic.
    Roasbeef committed Jan 25, 2022
    Copy the full SHA
    54f6fa9 View commit details
    Browse the repository at this point in the history
  8. Copy the full SHA
    0b245cc View commit details
    Browse the repository at this point in the history