-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
feat: Add testnet4 chain support #2274
feat: Add testnet4 chain support #2274
Conversation
Looks like we have another here: #2275 Neither that one, nor this one, have any of the new difficulty adjustment algorithm changes. |
I know that in #2275 they were working on the difficultly bits. @marcopeereboom I thought you had started on that part, is it in your PR? |
@Roasbeef @jcvernaleo thanks for your inputs. |
@bullet-tooth see the BIP: https://bips.dev/94/ |
Pull Request Test Coverage Report for Build 12318119030Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
Hey @Roasbeef, do you have any estimates about reviewing/merging this PR? |
If you clean up the PR into a review friendly commit structure, I'll take a look. |
c71544f
to
730a170
Compare
Hello, @guggero. Do you have any estimates when you will be able to review the PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update.
Still requires quite a bit of formal cleanup before more review time should be put in.
With "review friendly commit structure" I didn't mean squashing everything into a single commit.
Suggestion for commit order:
- Any comment/typo fixes.
- Any changes to non-Go files (e.g.
.gitignore
) - Add new parameter to
chaincfg
including unit tests. - Add
EnforceBip94
flag to parameters. - Add changes to
blockchain
package. - Add changes to
cmd
package.
blockchain/validate.go
Outdated
if c.ChainParams().EnforceBIP94 { | ||
// Check timestamp for the first block of each difficulty adjustment | ||
// interval, except the genesis block. | ||
if blockHeight%c.BlocksPerRetarget() == 0 { | ||
prevBlockTimestamp := time.Unix(prevNode.Timestamp(), 0) | ||
if header.Timestamp.Before(prevBlockTimestamp.Add(-maxTimeWarp)) { | ||
str := "block's timestamp %v is too early on diff adjustment block %v" | ||
str = fmt.Sprintf(str, header.Timestamp, prevBlockTimestamp) | ||
return ruleError(ErrTimewarpAttack, str) | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: line length. Also, sounds like this whole block could be extracted into a standalone function. Something like checkBip94()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure such an approach will improve the code quality because we need to pass parameters and handle errors anyway. So I decided not to introduce a new function
Great work @bullet-tooth - can't wait to see this PR being merged. |
730a170
to
09ba026
Compare
This PR adds support of the Bitcoin testnet version 4 chain (testnet3 is in a way of deprecation).
Reference: https://bips.dev/94/
Testnet4 genesis block: https://mempool.space/testnet4/block/00000000da84f2bafbbc53dee25a72ae507ff4914b867c565be350b0da8bf043
Also, I have intention to add testnet4 support to btcwallet after this PR