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

Versionbits: GBT support #7935

Merged
merged 4 commits into from Jun 8, 2016

Conversation

Projects
None yet
10 participants
@luke-jr
Member

luke-jr commented Apr 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).

@luke-jr

This comment has been minimized.

Show comment
Hide comment
@luke-jr

luke-jr Apr 27, 2016

Member

@sipa Added a commit to try to address the locking stuff cleaner.

Member

luke-jr commented Apr 27, 2016

@sipa Added a commit to try to address the locking stuff cleaner.

@theuni

View changes

Show outdated Hide outdated src/rpc/mining.cpp
@theuni

View changes

Show outdated Hide outdated src/versionbits.h
@theuni

View changes

Show outdated Hide outdated src/versionbits.cpp
@theuni

View changes

Show outdated Hide outdated src/rpc/mining.cpp
},
{
/*.name =*/ "csv",
/*.gbt_force =*/ true,

This comment has been minimized.

@theuni

theuni May 4, 2016

Member

Is a binary forced/not-forced enough?

Taking segwit as an example, post-activation, what would gbt_force = true mean? should I expect "segwit" to be always forced and transactions filtered? Forced if an commitment isn't required and an error otherwise? Isn't this a per-block property?

As gbt rules aren't necessarily static, I'm not sure that a simple flag makes sense. Or maybe I'm missing the bigger picture. Do you have that part coded up somewhere already, by chance?

@theuni

theuni May 4, 2016

Member

Is a binary forced/not-forced enough?

Taking segwit as an example, post-activation, what would gbt_force = true mean? should I expect "segwit" to be always forced and transactions filtered? Forced if an commitment isn't required and an error otherwise? Isn't this a per-block property?

As gbt rules aren't necessarily static, I'm not sure that a simple flag makes sense. Or maybe I'm missing the bigger picture. Do you have that part coded up somewhere already, by chance?

This comment has been minimized.

@luke-jr

luke-jr May 4, 2016

Member

This is just an internal detail to bitcoind, so we can change it in the future if needed. See how rpc/mining applies it in this PR...

@luke-jr

luke-jr May 4, 2016

Member

This is just an internal detail to bitcoind, so we can change it in the future if needed. See how rpc/mining applies it in this PR...

This comment has been minimized.

@theuni

theuni May 4, 2016

Member

Understood, I was just making the point that it's not really defining much so it's somewhat misleading. No problem making it more dynamic once that's required, though.

@theuni

theuni May 4, 2016

Member

Understood, I was just making the point that it's not really defining much so it's somewhat misleading. No problem making it more dynamic once that's required, though.

@theuni

This comment has been minimized.

Show comment
Hide comment
@theuni

theuni May 5, 2016

Member

ut ACK, other than the nits.

Member

theuni commented May 5, 2016

ut ACK, other than the nits.

@theuni

This comment has been minimized.

Show comment
Hide comment
@theuni

theuni May 5, 2016

Member

Needs some tests, though.

Member

theuni commented May 5, 2016

Needs some tests, though.

@sipa

View changes

Show outdated Hide outdated src/versionbits.h
@sipa

This comment has been minimized.

Show comment
Hide comment
@sipa

sipa May 9, 2016

Member

@luke-jr Can you revert the last commit? The design for having the data structure not do its own locking is very intentional.

Member

sipa commented May 9, 2016

@luke-jr Can you revert the last commit? The design for having the data structure not do its own locking is very intentional.

@luke-jr

This comment has been minimized.

Show comment
Hide comment
@luke-jr

luke-jr May 9, 2016

Member

Reverted... but it's what I thought you wanted.

Member

luke-jr commented May 9, 2016

Reverted... but it's what I thought you wanted.

@luke-jr

This comment has been minimized.

Show comment
Hide comment
@luke-jr

luke-jr May 13, 2016

Member

Updated for '!' prefix

Member

luke-jr commented May 13, 2016

Updated for '!' prefix

@jtimon

View changes

Show outdated Hide outdated src/rpc/mining.cpp
@sdaftuar

View changes

Show outdated Hide outdated src/rpc/mining.cpp
@@ -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 {

This comment has been minimized.

@jtimon

jtimon May 21, 2016

Member

Does this need to be with the consensus code?
Couldn't it be moved to miner.o or somewhere else?

@jtimon

jtimon May 21, 2016

Member

Does this need to be with the consensus code?
Couldn't it be moved to miner.o or somewhere else?

This comment has been minimized.

@luke-jr

luke-jr May 21, 2016

Member

Possibly. @sdaftuar was thinking maybe we should move the bit assignments here, however...

@luke-jr

luke-jr May 21, 2016

Member

Possibly. @sdaftuar was thinking maybe we should move the bit assignments here, however...

This comment has been minimized.

@jtimon

jtimon May 22, 2016

Member

I mean, I would say the only reason for not having versionbits.o in the consensus package already is because it still depends on chain.o (which is storage-dependent).

@jtimon

jtimon May 22, 2016

Member

I mean, I would say the only reason for not having versionbits.o in the consensus package already is because it still depends on chain.o (which is storage-dependent).

@jtimon

This comment has been minimized.

Show comment
Hide comment
@jtimon

jtimon May 21, 2016

Member

Fast-review ACK

Member

jtimon commented May 21, 2016

Fast-review ACK

@luke-jr

This comment has been minimized.

Show comment
Hide comment
@luke-jr

luke-jr May 29, 2016

Member

Tested with libblkmaker 0.5.3 (ie, using version/force) and bitcoin/libblkmaker#5 on testnet-in-a-box.

Member

luke-jr commented May 29, 2016

Tested with libblkmaker 0.5.3 (ie, using version/force) and bitcoin/libblkmaker#5 on testnet-in-a-box.

@sipa

This comment has been minimized.

Show comment
Hide comment
@sipa

sipa May 31, 2016

Member

utACK 46e8e06a5b62892024bf0da0e6104cc30a2a50cb. Squash some?

Member

sipa commented May 31, 2016

utACK 46e8e06a5b62892024bf0da0e6104cc30a2a50cb. Squash some?

@luke-jr

This comment has been minimized.

Show comment
Hide comment
@luke-jr

luke-jr Jun 1, 2016

Member

Squashing is a bad practice, so I prefer not to, if that's okay...

Member

luke-jr commented Jun 1, 2016

Squashing is a bad practice, so I prefer not to, if that's okay...

@MarcoFalke

This comment has been minimized.

Show comment
Hide comment
@MarcoFalke

MarcoFalke Jun 1, 2016

Member

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.

Member

MarcoFalke commented Jun 1, 2016

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.

@sipa

This comment has been minimized.

Show comment
Hide comment
@sipa

sipa Jun 1, 2016

Member
Member

sipa commented Jun 1, 2016

@gmaxwell

This comment has been minimized.

Show comment
Hide comment
@gmaxwell

gmaxwell Jun 1, 2016

Member

The merged tree is forever. We should favor post-merge reviewability.

Member

gmaxwell commented Jun 1, 2016

The merged tree is forever. We should favor post-merge reviewability.

@luke-jr

This comment has been minimized.

Show comment
Hide comment
@luke-jr

luke-jr Jun 1, 2016

Member

Squashed into 4 logical commits, and added a few comment lines explaining the logic around omitting a rule check for version/force.

Member

luke-jr commented Jun 1, 2016

Squashed into 4 logical commits, and added a few comment lines explaining the logic around omitting a rule check for version/force.

@theuni

View changes

Show outdated Hide outdated src/rpc/mining.cpp
@theuni

View changes

Show outdated Hide outdated src/consensus/params.h
@theuni

This comment has been minimized.

Show comment
Hide comment
@theuni

theuni Jun 6, 2016

Member

ut ACK, other than the nits above. I'll do thorough testing of segwit's implementation here.

Member

theuni commented 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

Implement BIP 9 GBT changes
- BIP9DeploymentInfo struct for static deployment info
- VersionBitsDeploymentInfo: Avoid C++11ism by commenting parameter names
- getblocktemplate: Make sure to set deployments in the version if it is LOCKED_IN
- In this commit, all rules are considered required for clients to support
@luke-jr

This comment has been minimized.

Show comment
Hide comment
@luke-jr

luke-jr Jun 6, 2016

Member

Nits fixed.

Member

luke-jr commented Jun 6, 2016

Nits fixed.

@sipa

This comment has been minimized.

Show comment
Hide comment
@sipa

sipa Jun 6, 2016

Member

utACK 12c708a

Member

sipa commented Jun 6, 2016

utACK 12c708a

@sipa

This comment has been minimized.

Show comment
Hide comment
@sipa

sipa Jun 8, 2016

Member

Also needs backport to 0.12.

Member

sipa commented Jun 8, 2016

Also needs backport to 0.12.

@sipa sipa merged commit 12c708a into bitcoin:master Jun 8, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

sipa added a commit that referenced this pull request Jun 8, 2016

Merge #7935: Versionbits: GBT support
12c708a getblocktemplate: Use version/force mutation to support pre-BIP9 clients (Luke Dashjr)
9879060 getblocktemplate: Explicitly handle the distinction between GBT-affecting softforks vs not (Luke Dashjr)
72cd6b2 qa/rpc-tests: bip9-softforks: Add tests for getblocktemplate versionbits updates (Luke Dashjr)
d3df40e Implement BIP 9 GBT changes (Luke Dashjr)

@sipa sipa referenced this pull request Jun 13, 2016

Closed

Segregated witness #7910

5 of 7 tasks complete

luke-jr added a commit to bitcoinknots/bitcoin that referenced this pull request Jun 27, 2016

@laanwj laanwj added this to the 0.12.2 milestone Sep 26, 2016

@fanquake fanquake removed the Needs backport label Mar 7, 2018

@dgenr8 dgenr8 referenced this pull request Sep 23, 2018

Open

bip9 cherries #488

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment