mirror of https://github.com/bitcoin/bitcoin
Merge f56480e5fe
into a46065e36c
This commit is contained in:
commit
ea5079ad65
|
@ -58,7 +58,8 @@ BIPs that are implemented by Bitcoin Core:
|
|||
Validation rules for Taproot (including Schnorr signatures and Tapscript
|
||||
leaves) are implemented as of **v0.21.0** ([PR 19953](https://github.com/bitcoin/bitcoin/pull/19953)),
|
||||
with mainnet activation as of **v0.21.1** ([PR 21377](https://github.com/bitcoin/bitcoin/pull/21377),
|
||||
[PR 21686](https://github.com/bitcoin/bitcoin/pull/21686)).
|
||||
[PR 21686](https://github.com/bitcoin/bitcoin/pull/21686)),
|
||||
always active as of **v24.0** ([PR 23536](https://github.com/bitcoin/bitcoin/pull/23536)).
|
||||
* [`BIP 350`](https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki): Addresses for native v1+ segregated Witness outputs use Bech32m instead of Bech32 as of **v22.0** ([PR 20861](https://github.com/bitcoin/bitcoin/pull/20861)).
|
||||
* [`BIP 371`](https://github.com/bitcoin/bips/blob/master/bip-0371.mediawiki): Taproot fields for PSBT as of **v24.0** ([PR 22558](https://github.com/bitcoin/bitcoin/pull/22558)).
|
||||
* [`BIP 380`](https://github.com/bitcoin/bips/blob/master/bip-0380.mediawiki)
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
RPC
|
||||
---
|
||||
|
||||
- 'taproot' has been removed from 'getdeploymentinfo' because its historical activation height is no longer used anywhere in the codebase. (#26201)
|
|
@ -18,6 +18,7 @@ namespace Consensus {
|
|||
/**
|
||||
* A buried deployment is one where the height of the activation has been hardcoded into
|
||||
* the client implementation long after the consensus change has activated. See BIP 90.
|
||||
* Consensus changes for which the new rules enforced from genesis are not listed here.
|
||||
*/
|
||||
enum BuriedDeployment : int16_t {
|
||||
// buried deployments get negative values to avoid overlap with DeploymentPos
|
||||
|
@ -25,14 +26,16 @@ enum BuriedDeployment : int16_t {
|
|||
DEPLOYMENT_CLTV,
|
||||
DEPLOYMENT_DERSIG,
|
||||
DEPLOYMENT_CSV,
|
||||
// SCRIPT_VERIFY_WITNESS is enforced from genesis, but the check for downloading
|
||||
// missing witness data is not. BIP 147 also relies on hardcoded activation height.
|
||||
DEPLOYMENT_SEGWIT,
|
||||
};
|
||||
constexpr bool ValidDeployment(BuriedDeployment dep) { return dep <= DEPLOYMENT_SEGWIT; }
|
||||
|
||||
enum DeploymentPos : uint16_t {
|
||||
DEPLOYMENT_TESTDUMMY,
|
||||
DEPLOYMENT_TAPROOT, // Deployment of Schnorr/Taproot (BIPs 340-342)
|
||||
// NOTE: Also add new deployments to VersionBitsDeploymentInfo in deploymentinfo.cpp
|
||||
// Removing an entry may require bumping MinBIP9WarningHeight.
|
||||
MAX_VERSION_BITS_DEPLOYMENTS
|
||||
};
|
||||
constexpr bool ValidDeployment(DeploymentPos dep) { return dep < MAX_VERSION_BITS_DEPLOYMENTS; }
|
||||
|
@ -95,7 +98,7 @@ struct Params {
|
|||
* BIP 16 exception blocks. */
|
||||
int SegwitHeight;
|
||||
/** Don't warn about unknown BIP 9 activations below this height.
|
||||
* This prevents us from warning about the CSV and segwit activations. */
|
||||
* This prevents us from warning about the CSV, segwit and taproot activations. */
|
||||
int MinBIP9WarningHeight;
|
||||
/**
|
||||
* Minimum blocks including miner confirmation of the total of 2016 blocks in a retargeting period,
|
||||
|
|
|
@ -13,10 +13,6 @@ const struct VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_B
|
|||
/*.name =*/ "testdummy",
|
||||
/*.gbt_force =*/ true,
|
||||
},
|
||||
{
|
||||
/*.name =*/ "taproot",
|
||||
/*.gbt_force =*/ true,
|
||||
},
|
||||
};
|
||||
|
||||
std::string DeploymentName(Consensus::BuriedDeployment dep)
|
||||
|
|
|
@ -85,7 +85,7 @@ public:
|
|||
consensus.BIP66Height = 363725; // 00000000000000000379eaa19dce8c9b722d46ae6a57c2f1a988119488b50931
|
||||
consensus.CSVHeight = 419328; // 000000000000000004a1b34462cb8aeebd5799177f7a29cf28f2d1961716b5b5
|
||||
consensus.SegwitHeight = 481824; // 0000000000000000001c8018d9cb3b742ef25114f27563e3fc4a1902167f9893
|
||||
consensus.MinBIP9WarningHeight = 483840; // segwit activation height + miner confirmation window
|
||||
consensus.MinBIP9WarningHeight = 711648; // taproot activation height + miner confirmation window
|
||||
consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
|
||||
consensus.nPowTargetSpacing = 10 * 60;
|
||||
|
@ -98,12 +98,6 @@ public:
|
|||
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].min_activation_height = 0; // No activation delay
|
||||
|
||||
// Deployment of Taproot (BIPs 340-342)
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].bit = 2;
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nStartTime = 1619222400; // April 24th, 2021
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = 1628640000; // August 11th, 2021
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 709632; // Approximately November 12th, 2021
|
||||
|
||||
consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000063c4ebd298db40af57541800");
|
||||
consensus.defaultAssumeValid = uint256S("0x000000000000000000026811d149d4d261995ec5b3f64f439a0a10e1a464af9a"); // 824000
|
||||
|
||||
|
@ -203,7 +197,7 @@ public:
|
|||
consensus.BIP66Height = 330776; // 000000002104c8c45e99a8853285a3b592602a3ccde2b832481da85e9e4ba182
|
||||
consensus.CSVHeight = 770112; // 00000000025e930139bac5c6c31a403776da130831ab85be56578f3fa75369bb
|
||||
consensus.SegwitHeight = 834624; // 00000000002b980fcd729daaa248fd9316a5200e9b367f4ff2c42453e84201ca
|
||||
consensus.MinBIP9WarningHeight = 836640; // segwit activation height + miner confirmation window
|
||||
consensus.MinBIP9WarningHeight = 2013984; // taproot activation height + miner confirmation window
|
||||
consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
|
||||
consensus.nPowTargetSpacing = 10 * 60;
|
||||
|
@ -216,12 +210,6 @@ public:
|
|||
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].min_activation_height = 0; // No activation delay
|
||||
|
||||
// Deployment of Taproot (BIPs 340-342)
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].bit = 2;
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nStartTime = 1619222400; // April 24th, 2021
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = 1628640000; // August 11th, 2021
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 0; // No activation delay
|
||||
|
||||
consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000000000c59b14e264ba6c15db9");
|
||||
consensus.defaultAssumeValid = uint256S("0x000000000001323071f38f21ea5aae529ece491eadaccce506a59bcc2d968917"); // 2550000
|
||||
|
||||
|
@ -353,12 +341,6 @@ public:
|
|||
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].min_activation_height = 0; // No activation delay
|
||||
|
||||
// Activation of Taproot (BIPs 340-342)
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].bit = 2;
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 0; // No activation delay
|
||||
|
||||
// message start is defined as the first 4 bytes of the sha256d of the block script
|
||||
HashWriter h{};
|
||||
h << consensus.signet_challenge;
|
||||
|
@ -430,11 +412,6 @@ public:
|
|||
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].min_activation_height = 0; // No activation delay
|
||||
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].bit = 2;
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 0; // No activation delay
|
||||
|
||||
consensus.nMinimumChainWork = uint256{};
|
||||
consensus.defaultAssumeValid = uint256{};
|
||||
|
||||
|
|
|
@ -1339,7 +1339,6 @@ UniValue DeploymentInfo(const CBlockIndex* blockindex, const ChainstateManager&
|
|||
SoftForkDescPushBack(blockindex, softforks, chainman, Consensus::DEPLOYMENT_CSV);
|
||||
SoftForkDescPushBack(blockindex, softforks, chainman, Consensus::DEPLOYMENT_SEGWIT);
|
||||
SoftForkDescPushBack(blockindex, softforks, chainman, Consensus::DEPLOYMENT_TESTDUMMY);
|
||||
SoftForkDescPushBack(blockindex, softforks, chainman, Consensus::DEPLOYMENT_TAPROOT);
|
||||
return softforks;
|
||||
}
|
||||
} // anon namespace
|
||||
|
@ -1347,7 +1346,8 @@ UniValue DeploymentInfo(const CBlockIndex* blockindex, const ChainstateManager&
|
|||
RPCHelpMan getdeploymentinfo()
|
||||
{
|
||||
return RPCHelpMan{"getdeploymentinfo",
|
||||
"Returns an object containing various state info regarding deployments of consensus changes.",
|
||||
"Returns an object containing various state info regarding deployments of consensus changes.\n"
|
||||
"Consensus changes for which the new rules are enforced from genesis are not listed here.",
|
||||
{
|
||||
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Default{"hash of current chain tip"}, "The block hash at which to query deployment state"},
|
||||
},
|
||||
|
|
|
@ -620,7 +620,7 @@ static RPCHelpMan getblocktemplate()
|
|||
{RPCResult::Type::NUM, "", "transactions before this one (by 1-based index in 'transactions' list) that must be present in the final block if this one is"},
|
||||
}},
|
||||
{RPCResult::Type::NUM, "fee", "difference in value between transaction inputs and outputs (in satoshis); for coinbase transactions, this is a negative Number of the total collected block fees (ie, not including the block subsidy); if key is not present, fee is unknown and clients MUST NOT assume there isn't one"},
|
||||
{RPCResult::Type::NUM, "sigops", "total SigOps cost, as counted for purposes of block limits; if key is not present, sigop cost is unknown and clients MUST NOT assume it is zero"},
|
||||
{RPCResult::Type::NUM, "sigops", "sigops cost for transaction, as counted for purposes of block limits"},
|
||||
{RPCResult::Type::NUM, "weight", "total transaction weight, as counted for purposes of block limits"},
|
||||
}},
|
||||
}},
|
||||
|
@ -821,9 +821,6 @@ static RPCHelpMan getblocktemplate()
|
|||
UpdateTime(pblock, consensusParams, pindexPrev);
|
||||
pblock->nNonce = 0;
|
||||
|
||||
// NOTE: If at some point we support pre-segwit miners post-segwit-activation, this needs to take segwit support into consideration
|
||||
const bool fPreSegWit = !DeploymentActiveAfter(pindexPrev, chainman, Consensus::DEPLOYMENT_SEGWIT);
|
||||
|
||||
UniValue aCaps(UniValue::VARR); aCaps.push_back("proposal");
|
||||
|
||||
UniValue transactions(UniValue::VARR);
|
||||
|
@ -854,10 +851,6 @@ static RPCHelpMan getblocktemplate()
|
|||
int index_in_template = i - 1;
|
||||
entry.pushKV("fee", pblocktemplate->vTxFees[index_in_template]);
|
||||
int64_t nTxSigOps = pblocktemplate->vTxSigOpsCost[index_in_template];
|
||||
if (fPreSegWit) {
|
||||
CHECK_NONFATAL(nTxSigOps % WITNESS_SCALE_FACTOR == 0);
|
||||
nTxSigOps /= WITNESS_SCALE_FACTOR;
|
||||
}
|
||||
entry.pushKV("sigops", nTxSigOps);
|
||||
entry.pushKV("weight", GetTransactionWeight(tx));
|
||||
|
||||
|
@ -877,8 +870,13 @@ static RPCHelpMan getblocktemplate()
|
|||
result.pushKV("capabilities", aCaps);
|
||||
|
||||
UniValue aRules(UniValue::VARR);
|
||||
// See getblocktemplate changes in BIP 9:
|
||||
// ! indicates a more subtle change to the block structure or generation transaction
|
||||
// Otherwise clients may assume the rule will not impact usage of the template as-is.
|
||||
aRules.push_back("csv");
|
||||
if (!fPreSegWit) aRules.push_back("!segwit");
|
||||
// BIP 145: the '!' rule prefix MUST be enabled on the "segwit" rule for templates including transactions with witness data.
|
||||
aRules.push_back("!segwit");
|
||||
aRules.push_back("taproot");
|
||||
if (consensusParams.signet_blocks) {
|
||||
// indicate to miner that they must understand signet rules
|
||||
// when attempting to mine with this template
|
||||
|
@ -941,17 +939,9 @@ static RPCHelpMan getblocktemplate()
|
|||
result.pushKV("noncerange", "00000000ffffffff");
|
||||
int64_t nSigOpLimit = MAX_BLOCK_SIGOPS_COST;
|
||||
int64_t nSizeLimit = MAX_BLOCK_SERIALIZED_SIZE;
|
||||
if (fPreSegWit) {
|
||||
CHECK_NONFATAL(nSigOpLimit % WITNESS_SCALE_FACTOR == 0);
|
||||
nSigOpLimit /= WITNESS_SCALE_FACTOR;
|
||||
CHECK_NONFATAL(nSizeLimit % WITNESS_SCALE_FACTOR == 0);
|
||||
nSizeLimit /= WITNESS_SCALE_FACTOR;
|
||||
}
|
||||
result.pushKV("sigoplimit", nSigOpLimit);
|
||||
result.pushKV("sizelimit", nSizeLimit);
|
||||
if (!fPreSegWit) {
|
||||
result.pushKV("weightlimit", (int64_t)MAX_BLOCK_WEIGHT);
|
||||
}
|
||||
result.pushKV("weightlimit", (int64_t)MAX_BLOCK_WEIGHT);
|
||||
result.pushKV("curtime", pblock->GetBlockTime());
|
||||
result.pushKV("bits", strprintf("%08x", pblock->nBits));
|
||||
result.pushKV("height", (int64_t)(pindexPrev->nHeight+1));
|
||||
|
|
|
@ -3889,6 +3889,7 @@ bool CheckBlock(const CBlock& block, BlockValidationState& state, const Consensu
|
|||
strprintf("Transaction check failed (tx hash %s) %s", tx->GetHash().ToString(), tx_state.GetDebugMessage()));
|
||||
}
|
||||
}
|
||||
// This underestimates the number of sigops, because unlike ConnectBlock it does not count the witness:
|
||||
unsigned int nSigOps = 0;
|
||||
for (const auto& tx : block.vtx)
|
||||
{
|
||||
|
|
|
@ -84,21 +84,18 @@ class SegWitTest(BitcoinTestFramework):
|
|||
def set_test_params(self):
|
||||
self.setup_clean_chain = True
|
||||
self.num_nodes = 3
|
||||
# This test tests SegWit both pre and post-activation, so use the normal BIP9 activation.
|
||||
# This test tests SegWit post-activation
|
||||
self.extra_args = [
|
||||
[
|
||||
"-acceptnonstdtxn=1",
|
||||
"-testactivationheight=segwit@165",
|
||||
"-addresstype=legacy",
|
||||
],
|
||||
[
|
||||
"-acceptnonstdtxn=1",
|
||||
"-testactivationheight=segwit@165",
|
||||
"-addresstype=legacy",
|
||||
],
|
||||
[
|
||||
"-acceptnonstdtxn=1",
|
||||
"-testactivationheight=segwit@165",
|
||||
"-addresstype=legacy",
|
||||
],
|
||||
]
|
||||
|
@ -124,17 +121,6 @@ class SegWitTest(BitcoinTestFramework):
|
|||
def run_test(self):
|
||||
self.generate(self.nodes[0], 161) # block 161
|
||||
|
||||
self.log.info("Verify sigops are counted in GBT with pre-BIP141 rules before the fork")
|
||||
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1)
|
||||
tmpl = self.nodes[0].getblocktemplate({'rules': ['segwit']})
|
||||
assert_equal(tmpl['sizelimit'], 1000000)
|
||||
assert 'weightlimit' not in tmpl
|
||||
assert_equal(tmpl['sigoplimit'], 20000)
|
||||
assert_equal(tmpl['transactions'][0]['hash'], txid)
|
||||
assert_equal(tmpl['transactions'][0]['sigops'], 2)
|
||||
assert '!segwit' not in tmpl['rules']
|
||||
self.generate(self.nodes[0], 1) # block 162
|
||||
|
||||
balance_presetup = self.nodes[0].getbalance()
|
||||
self.pubkey = []
|
||||
p2sh_ids = [] # p2sh_ids[NODE][TYPE] is an array of txids that spend to P2WPKH (TYPE=0) or P2WSH (TYPE=1) scripts to an address for NODE embedded in p2sh
|
||||
|
|
|
@ -174,6 +174,9 @@ class MiningTest(BitcoinTestFramework):
|
|||
self.log.info("getblocktemplate: segwit rule must be set")
|
||||
assert_raises_rpc_error(-8, "getblocktemplate must be called with the segwit rule set", node.getblocktemplate, {})
|
||||
|
||||
self.log.info("getblocktemplate: result should set the right rules")
|
||||
assert_equal(['csv', '!segwit', 'taproot'], self.nodes[0].getblocktemplate(NORMAL_GBT_REQUEST_PARAMS)['rules'])
|
||||
|
||||
self.log.info("getblocktemplate: Test valid block")
|
||||
assert_template(node, block, None)
|
||||
|
||||
|
|
|
@ -224,19 +224,6 @@ class BlockchainTest(BitcoinTestFramework):
|
|||
},
|
||||
'active': False
|
||||
},
|
||||
'taproot': {
|
||||
'type': 'bip9',
|
||||
'bip9': {
|
||||
'start_time': -1,
|
||||
'timeout': 9223372036854775807,
|
||||
'min_activation_height': 0,
|
||||
'status': 'active',
|
||||
'status_next': 'active',
|
||||
'since': 0,
|
||||
},
|
||||
'height': 0,
|
||||
'active': True
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue