Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
Versionbits: GBT support #7935
Conversation
jonasschnelli
added
the
Mining
label
Apr 25, 2016
|
@sipa Added a commit to try to address the locking stuff cleaner. |
theuni
and 1 other
commented on an outdated diff
May 3, 2016
| UniValue result(UniValue::VOBJ); | ||
| result.push_back(Pair("capabilities", aCaps)); | ||
| + | ||
| + UniValue aRules(UniValue::VARR); | ||
| + UniValue vbavailable(UniValue::VOBJ); | ||
| + const std::vector<ThresholdState> vbstates = versionbitscache.GetAllThresholdStates(pindexPrev, cparams); | ||
| + for (int i = 0; i < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++i) { |
theuni
Member
|
theuni
and 1 other
commented on an outdated diff
May 3, 2016
| @@ -30,6 +30,8 @@ enum ThresholdState { | ||
| // will either be NULL or a block with (height + 1) % Period() == 0. | ||
| typedef std::map<const CBlockIndex*, ThresholdState> ThresholdConditionCache; | ||
| +extern const char * const VersionBitsDeploymentNames[]; |
luke-jr
Member
|
theuni
commented on an outdated diff
May 3, 2016
| for (unsigned int d = 0; d < Consensus::MAX_VERSION_BITS_DEPLOYMENTS; d++) { | ||
| caches[d].clear(); | ||
| } | ||
| } | ||
| + | ||
| +ThresholdState VersionBitsCache::VersionBitsState(const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::DeploymentPos pos) | ||
| +{ | ||
| + LOCK(cs); | ||
| + return VersionBitsConditionChecker(pos).CachedGetStateFor(pindexPrev, params, caches[pos]); | ||
| +} | ||
| + | ||
| +std::vector<ThresholdState> VersionBitsCache::GetAllThresholdStates(const CBlockIndex* pindexPrev, const Consensus::Params& params) | ||
| +{ | ||
| + std::vector<ThresholdState> ret; | ||
| + ret.reserve((int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS); | ||
| + LOCK(cs); | ||
| + for (int i = 0; i < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++i) { |
theuni
Member
|
theuni
commented on an outdated diff
May 3, 2016
| @@ -369,6 +380,17 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) | ||
| TestBlockValidity(state, Params(), block, pindexPrev, false, true); | ||
| return BIP22ValidationResult(state); | ||
| } | ||
| + | ||
| + const UniValue& aClientRules = find_value(oparam, "rules"); | ||
| + if (aClientRules.isArray()) { | ||
| + for (unsigned int i = 0; i < aClientRules.size(); ++i) { | ||
| + const UniValue& v = aClientRules[i]; | ||
| + setClientRules.insert(v.get_str()); | ||
| + } | ||
| + } else { | ||
| + const UniValue& uvMaxVersion = find_value(oparam, "maxversion"); |
|
|
theuni
commented on the diff
May 4, 2016
| @@ -4,7 +4,20 @@ | ||
| #include "versionbits.h" | ||
| -ThresholdState AbstractThresholdConditionChecker::GetStateFor(const CBlockIndex* pindexPrev, const Consensus::Params& params, ThresholdConditionCache& cache) const | ||
| +#include "consensus/params.h" | ||
| + | ||
| +const struct BIP9DeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_BITS_DEPLOYMENTS] = { | ||
| + { | ||
| + /*.name =*/ "testdummy", | ||
| + /*.gbt_force =*/ true, | ||
| + }, | ||
| + { | ||
| + /*.name =*/ "csv", | ||
| + /*.gbt_force =*/ true, |
theuni
Member
|
|
ut ACK, other than the nits. |
|
Needs some tests, though. |
sipa
commented on an outdated diff
May 9, 2016
| { | ||
| +private: | ||
| + CCriticalSection cs; |
sipa
Owner
|
|
@luke-jr Can you revert the last commit? The design for having the data structure not do its own locking is very intentional. |
|
Reverted... but it's what I thought you wanted. |
|
Updated for '!' prefix |
luke-jr
referenced this pull request
May 18, 2016
Closed
[0.11] Backport BIP9 and softfork for BIP's 68,112,113 #7716
jtimon
commented on an outdated diff
May 20, 2016
| @@ -458,9 +490,10 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) | ||
| pindexPrev = pindexPrevNew; | ||
| } | ||
| CBlock* pblock = &pblocktemplate->block; // pointer for convenience | ||
| + const Consensus::Params& cparams = Params().GetConsensus(); |
jtimon
Member
|
sdaftuar
and 1 other
commented on an outdated diff
May 21, 2016
| + UniValue vbavailable(UniValue::VOBJ); | ||
| + for (int i = 0; i < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++i) { | ||
| + Consensus::DeploymentPos pos = Consensus::DeploymentPos(i); | ||
| + ThresholdState state = VersionBitsState(pindexPrev, consensusParams, pos, versionbitscache); | ||
| + switch (state) { | ||
| + case THRESHOLD_DEFINED: | ||
| + case THRESHOLD_FAILED: | ||
| + // Not exposed to GBT at all | ||
| + break; | ||
| + case THRESHOLD_LOCKED_IN: | ||
| + // Ensure bit is set in block version | ||
| + pblock->nVersion |= VersionBitsMask(consensusParams, pos); | ||
| + // FALL THROUGH to get vbavailable set... | ||
| + case THRESHOLD_STARTED: | ||
| + // Add to vbavailable (and it's presumably in version already) | ||
| + vbavailable.push_back(Pair(gbt_vb_name(pos), consensusParams.vDeployments[pos].bit)); |
sdaftuar
Member
|
jtimon
commented on the diff
May 21, 2016
| @@ -30,6 +30,15 @@ enum ThresholdState { | ||
| // will either be NULL or a block with (height + 1) % Period() == 0. | ||
| typedef std::map<const CBlockIndex*, ThresholdState> ThresholdConditionCache; | ||
| +struct BIP9DeploymentInfo { |
jtimon
Member
|
|
Fast-review ACK |
mrCertified
referenced this pull request
May 25, 2016
Closed
Option for disabling the system tray #7160
|
Tested with libblkmaker 0.5.3 (ie, using version/force) and bitcoin/libblkmaker#5 on testnet-in-a-box. |
|
utACK 46e8e06a5b62892024bf0da0e6104cc30a2a50cb. Squash some? |
|
Squashing is a bad practice, so I prefer not to, if that's okay... |
|
There is 12 commits, so squashing would help to not bury the previous code under several layers of history. Not to mention that squashing would make it probably easier to read the commits of this pull. |
|
Squashing is worse for retaining the history of the patch and downstream
branches, but better for post-merge reviewability. I think that as a
project, we favor having good transparency of the changes over the exact
history that led to the development of those changes.
|
|
The merged tree is forever. We should favor post-merge reviewability. |
|
Squashed into 4 logical commits, and added a few comment lines explaining the logic around omitting a rule check for version/force. |
theuni
and 1 other
commented on an outdated diff
Jun 4, 2016
| @@ -544,13 +555,29 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) | ||
| pblock->nVersion |= VersionBitsMask(consensusParams, pos); | ||
| // FALL THROUGH to get vbavailable set... | ||
| case THRESHOLD_STARTED: | ||
| - // Add to vbavailable (and it's presumably in version already) | ||
| - vbavailable.push_back(Pair(gbt_vb_name(pos), consensusParams.vDeployments[pos].bit)); | ||
| + { | ||
| + const struct BIP9DeploymentInfo& vbinfo = VersionBitsDeploymentInfo[pos]; vbavailable.push_back(Pair(gbt_vb_name(pos), consensusParams.vDeployments[pos].bit)); |
|
|
theuni
commented on an outdated diff
Jun 6, 2016
|
ut ACK, other than the nits above. I'll do thorough testing of segwit's implementation here. |
luke-jr
added some commits
Apr 23, 2016
|
Nits fixed. |
|
utACK 12c708a |
|
Also needs backport to 0.12. |
luke-jr commentedApr 25, 2016
•
Edited 1 time
-
luke-jr
May 25, 2016
Versionbits was released in 0.12.1, but only included updates for the consensus layer. Due to the low-level design of GBT, it is currently not possible to use in practice, since the client has no way to identify the meaning of the block version anymore. Miners and pools can as a hack override/ignore the block version entirely, but this is not really a solution.
This change adds the necessary versionbits information to GBT so that miners can implement it safely.
It also detects when the client is outdated, but can still safely use the template as-is, and uses the GBT version/force and/or rules/force mutability flags to indicate that. This enables older miners that only support at least BIP 34 (block v2) to work with the newer bitcoind. Obviously this is a very short-term benefit in practice, since segwit necessarily will break such miners, but will become useful again as soon as the next simple softfork is deployed (in which case clients need only support segwit).