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

Disable retargeting on regtest to preserve compatibility with bitcoind #256

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions blockmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -2736,6 +2736,11 @@ func (b *blockManager) checkHeaderSanity(blockHeader *wire.BlockHeader,
func (b *blockManager) calcNextRequiredDifficulty(newBlockTime time.Time,
reorgAttempt bool) (uint32, error) {

// bitcoind doesn't do retargeting on regtest, we do the same to ensure compatibility
Copy link
Member

Choose a reason for hiding this comment

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

This looks a bit hacky indeed... bitcoind solved it by adding another boolean to the chain params: https://github.com/bitcoin/bitcoin/blob/e695d8536e534f1e59de4a62a0d87a93e7a73456/src/kernel/chainparams.cpp#L415
Perhaps we should do the same in btcd? Then we could solve it for both Neutrino and btcd.

Copy link
Contributor

@chappjc chappjc Jun 12, 2023

Choose a reason for hiding this comment

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

This should be straightforward since blockManagerCfg has the params stored.

For reference: https://github.com/bitcoin/bitcoin/pull/6853/files

Would you be able to tweak this PR like that @amanzag? Thanks so much for addressing this inconsistency with bitcoind.

Copy link
Member

Choose a reason for hiding this comment

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

I have a PR up in btcd that can be re-used here once merged: btcsuite/btcd#1985

Copy link
Contributor

Choose a reason for hiding this comment

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

Missed that, Great!

if b.cfg.ChainParams.Name == "regtest" {
return b.cfg.ChainParams.PowLimitBits, nil
}

hList := b.headerList
if reorgAttempt {
hList = b.reorgList
Expand Down