Add bip94 setting for Testnet4#792
Conversation
|
I am able to sync testnet4 with a config like this: |
|
@pmienk What's the proper way to have PRs like this with dependent branches complete? |
This is a default (mainnet), no need to include. |
|
|
||
| if [[ -z ${libbitcoin_system_OWNER} ]]; then | ||
| libbitcoin_system_OWNER="libbitcoin" | ||
| libbitcoin_system_OWNER="thecodefactory" |
There was a problem hiding this comment.
No, I was trying to see if it would pull my branches to pass CI, but I'll remove that stuff because it didn't work anyway
There was a problem hiding this comment.
If you merge them all in your own repos you can get a result spanning all of them. This was a change that @pmienk make a few months ago. As for the origin repo, there's no better answer for that - but if you pull them all it should generally be after you've verified them all in your repo. Then when they are all good to go we can merge them all quickly in origin.
| ( | ||
| "forks.bip94", | ||
| value<bool>(&configured.bitcoin.forks.bip94), | ||
| "Assume bip94 activation if enabled, defaults to 'true' (hard fork)." |
There was a problem hiding this comment.
This should be moved to the top section with these:
/* [forks] */
(
"forks.difficult",
value<bool>(&configured.bitcoin.forks.difficult),
"Require difficult blocks, defaults to 'true' (use false for testnet)."
)
(
"forks.retarget",
value<bool>(&configured.bitcoin.forks.retarget),
"Retarget difficulty, defaults to 'true' (use false for regtest)."
)or to the bottom with these:
(
"forks.time_warp_patch",
value<bool>(&configured.bitcoin.forks.time_warp_patch),
"Fix time warp bug, defaults to 'false' (hard fork)."
)
(
"forks.retarget_overflow_patch",
value<bool>(&configured.bitcoin.forks.retarget_overflow_patch),
"Fix target overflow for very low difficulty, defaults to 'false' (hard fork)."
)
(
"forks.scrypt_proof_of_work",
value<bool>(&configured.bitcoin.forks.scrypt_proof_of_work),
"Use scrypt hashing for proof of work, defaults to 'false' (hard fork)."
)Assume bip94 activation if enabled, defaults to 'true' (hard fork).
Must default tofalse, the "assume activation" text isn't applicable here, should be more similar to the litecoin comments.
BIP fork settings are named so that they can default to true (as are retarget and difficult). If this one does as well (as described in its text) it would need to be named not_bip94). The reason for this is that we want the flags representation (e.g. in the store and in the console log for example) to reflect all zeros until a fork activates. It might be better to not actually call this bip94.
Also in bip94:
- 20-minute Exception Rule
This rule was implemented in Testnet 3[2] and is preserved in Testnet 4.
So as you showed in the config, this part of bip94 is implemented in a distinct fork. And this config is therefore activating a pair of additional forks ("Block Storm Fix", "Time Warp Attack Prevention"). Which means by default, there is a "block storm" behavior and a "time warp" behavior, that are enabled, and this fork disables them.
Note that we have these three settings for litecoin:
/// Litecoin rules.
/// -----------------------------------------------------------------------
/// Fix Satoshi's time warp bug (hard fork, security).
time_warp_patch = bit_right<uint32_t>(17),
/// Fix target overflow for very low difficulty (hard fork, security).
retarget_overflow_patch = bit_right<uint32_t>(18),
/// Use scrypt hashing for proof of work (hard fork, feature).
scrypt_proof_of_work = bit_right<uint32_t>(19), forks.time_warp_patch = false; // litecoin
forks.retarget_overflow_patch = false; // litecoin
forks.scrypt_proof_of_work = false; // litecoin[And we are using up our 32 flag space (impacts database schema/size).]
bip94 describes a second "time warp patch" (not sure why this different one was chosen, ltc has had this forever).
This rule is based on The Great Consensus Cleanup proposal.
This implies that this could become non-testnet rule. I would not implement the "cleanup" rules as one rule either, as they are entirely independent rules. So this "time warp patch" could just eventually be re-labelled/activated as one of those.
JR has proposed independent BIPs for the three "cleanup" forks. Might be worth taking the name from that one. In any case we need to deconflict with time_warp_patch that we already have.
bip94 also defines a "block storm patch" to the problems cause by the !difficult testnet3 fork. Since it describes these as two distinct rules they probably should be. So for this one I would call the flag:
/// Address block storms caused by !difficult rule (hard fork, testnet4).
block_storm_patch = bit_right<uint32_t>(...)There was a problem hiding this comment.
This was a mistake: "Assume bip94 activation if enabled, defaults to 'true' (hard fork)." -- It should in fact default to false
There was a problem hiding this comment.
To resolve the naming conflicts above I recommend the approach of prefixing altcoin-only forks with the a chain identifier, eg:
forks.ltc_time_warp_patch = false;
forks.ltc_retarget_overflow_patch = false;
forks.ltc_scrypt_proof_of_work = false;
And grouping them at the bottom (high end) of flags (so they appear together as 1) in the bit matrix.
Which frees up this distinct time_warp_patch name, which can be combined with block_storm_patch. I would implement these as distinct forks for btc (unprefixed), and set them in a group just after ltc (for now, this preserves compat with existing stores), for both flags and forks enums.
So a distinct set of PRs to add ltc_ and then rebase over that.
There was a problem hiding this comment.
I'm not opposed to splitting things up more with additional settings/flags, but there are 2 reasons I think we shouldn't: 1) bip94 is either implemented/enforced, or it's not (there's no independent path for the changes so far, at least that's specified in that bip), and 2) as you noted, we're running out of flag bits. I'm ok with not_bip94 based on the fact that we want the setting to be true by default. I'm also not that strongly tied to the setting names, so if you have a preference for both or just a single one, I'll go with that.
There was a problem hiding this comment.
Just saw your previous comment now (sorry, didn't reload the page I guess before posting my last response). Sounds good though
Depends on libbitcoin/libbitcoin-system#1866 and libbitcoin/libbitcoin-node#1034