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+chaincfg: disable retargeting for regtest #1985

Merged
merged 1 commit into from
Jun 22, 2023

Conversation

guggero
Copy link
Collaborator

@guggero guggero commented May 23, 2023

This commit emulates the behavior of Bitcoin Core introduced in bitcoin/bitcoin#6853 that disables retargeting of the required proof of work for regtest.

Attempts to fix lightninglabs/neutrino#256 in a less hacky way (needs a PR in that repo as well after this one has been merged).

@guggero guggero requested a review from Roasbeef May 23, 2023 13:36
@coveralls
Copy link

coveralls commented May 23, 2023

Pull Request Test Coverage Report for Build 5342782675

  • 7 of 7 (100.0%) changed or added relevant lines in 1 file are covered.
  • 23 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.04%) to 55.22%

Files with Coverage Reduction New Missed Lines %
blockchain/difficulty.go 23 48.78%
Totals Coverage Status
Change from base Build 5336862129: -0.04%
Covered Lines: 26644
Relevant Lines: 48251

💛 - Coveralls

Copy link
Contributor

@yyforyongyu yyforyongyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up! Something I also wanted to do as it can save us quite some blocks in lnd's itest!

Copy link
Collaborator

@kcalvinalvin kcalvinalvin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok otherwise


// Emulate the same behavior as Bitcoin Core that for regtest there is
// no difficulty retargeting.
if b.chainParams.PoWNoRetargeting {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is only desired for Regtest (maybe simnet in btcd as well?), how about something like:

       if b.chainParams.Name == chaincfg.RegressionNetParams.Name {

instead of introducing a new field in Params?.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this makes it just way more explicit what's going on. See lightninglabs/neutrino#256 (comment) 😅

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. Ok seems alright

@kcalvinalvin
Copy link
Collaborator

ACK cf802a0

Copy link
Contributor

@chappjc chappjc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just a note about the initial objections from @davecgh, but I think the ship has sailed on this since it's what bitcoind does and apps like neutrino need to match.

@Roasbeef
Copy link
Member

but I think the ship has sailed on this since it's what bitcoind does and apps like neutrino need to match.

FWIW simnet does do retargeting, so applications that depend on being able to replicate such behavior can use that in place.

Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 💫

Needs rebase.

This commit emulates the behavior of Bitcoin Core introduced in
bitcoin/bitcoin#6853 that disables retargeting
of the required proof of work for regtest.
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.

6 participants