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

blockchain/stake: Introduce v2 module. #1803

Merged
merged 14 commits into from
Jul 29, 2019

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Jul 26, 2019

In order to make use of chaincfg/v2, dcrutil/v2, and database/v2, a new major version of the blockchain/stake module is required because blockchain/stake/v1 accepts and returns types from chaincfg/v1, dcrutil/v1, and database/v1 in its API.

Since a new major version is required, this also takes the opportunity to address a few other items that require a new major version as follows:

  • It directly accepts *chaincfg.Params in its API funcs which tightly couples it to the specific version of chaincfg. This forces major version bumps of the blockchain/stake module when the major version of chaincfg is bumped even if nothing in it blockchain/stake actually relies on the changes.
  • DisableLog is deprecated.
  • TxSSGenStakeOutputInfo is part of the public API, but is no longer used.
  • TxSSRtxStakeOutputInfo is part of the public API, but is no longer used.
  • SetTxTree is part of the public API, but is neither used nor needed.

Consequently, this introduces blockchain/stake/v2 which addresses the aforementioned items. A series of individual commits is provided to make the review process easier. Each commit message more thoroughly describes its purpose, but primarily they consist of the following:

  • Freeze version 1 of the blockchain/stake module
  • Remove the root module blockchain/stake override so building the software will still produce binaries based on the v1 module until the v2 module is fully released
  • Make doc.go formatting consistent.
  • Correct comment typo on Hash256PRNG.
  • Remove DisableLog.
  • Remove unused TxSSGenStakeOutputInfo.
  • Remove unused TxSSRtxStakeOutputInfo.
  • Remove unused SetTxTree.
  • Introduce a new StakeParams interface that is limited specifically to the stake-related parameters needed and update all APIs that previously accepted *chaincfg.Params for that purpose to use the new interface instead.
  • Convert the tests to use mock params that satisfy the interface thus preventing test failures if chaincfg changes
  • Update to use dcrutil/v2@v2.0.0
  • Update to use chaincfg/v2@v2.1.0
  • Update to use txscript/v2@v2.0.0
  • Update to use database/v2@v2.0.0
  • Update all APIs that deal with addresses and previously accepted *chaincfg.Params to accept the dcrutil.AddressParams interface instead.
  • Bump the module version to v2
  • Update docs for the new module version

Finally, it should also be noted that this only introduces the new module and does not update anything to make use of it yet, so building the software will still produce binaries based on the v1 module.

@davecgh davecgh added this to the 1.5.0 milestone Jul 26, 2019
This serves as the final release of version 1 of the blockchain/stake
module.  All future releases will be moving to version 2 of the module.

Consequently, it bumps the required module version as follows:

- github.com/decred/dcrd/blockchain/stake@v1.2.0

It also removes the blockchain/stake override in the root module and
updates it so building the software will still produce binaries based on
the v1 module until the v2 module is fully released.
This removes the TxSSGenStakeOutputInfo since it is no longer used.
This removes the TxSSRtxStakeOutputInfo since it is no longer used.
This removes SetTxTree since it is no longer used.
This introduces a new interface named StakeParams and updates the
functions that currently take a pointer to a chaincfg.Params struct to
accept the interface instead.

This removes the tight coupling between the two packages at the API
boundary and allows callers to easily provide custom values if desired.

It also updates the tests to make use of the interface by adding and
using a mock stake params struct the implements the new interface.  The
new struct is defined in terms of a chaincfg.Params for now for
convenience, but the interface design means it is possible to define
them independently in the future as needed.
This udpates the blockchain/stake module to use v2 of the dcrutil module
and v2 of the chaincfg module since dcrutil/v2 requires it.

It also updates the tests accordingly.

The updated direct dependencies are as follows:

- github.com/decred/dcrd/chaincfg/v2@v2.1.0
- github.com/decred/dcrd/dcrutil/v2@v2.0.0
This udpates the blockchain/stake module to use v2 of the txscript module.

The updated direct dependencies are as follows:

- github.com/decred/dcrd/txscript/v2@v2.0.0
This udpates the blockchain/stake module to use v2 of the database module.

The updated direct dependencies are as follows:

- github.com/decred/dcrd/database/v2@v2.0.0
This modifies the AddrFromSStxPkScrCommitment function to accept a
dcrutil.AddressParams interface instead of a concrete chaincfg.Params to
remove the tight coupling between the two packages at the API boundary
and allow callers to easily provide custom values if desired.  # Please
enter the commit message for your changes. Lines starting
@davecgh davecgh merged commit 051fa9f into decred:master Jul 29, 2019
@davecgh davecgh deleted the stake_introduce_v2 branch July 29, 2019 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants