Repository navigation
feat: Taproot (BIP 340/341/342) without SegWit, activated by the taproot EHF deployment - experimental
#8089
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
base: develop
Are you sure you want to change the base?
Changes from all commits
b55ff1b
d44c3e6
1d1b779
5e1c869
39792a3
a93abb6
785dfe4
e8fb0bd
2827113
2a4ef46
e4a6880
38c7226
f8c76ca
67f6e2f
d44f486
a774990
ecdf684
da6cd81
82f033f
4be1a7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,7 @@ enum DeploymentPos : uint16_t { | |
| DEPLOYMENT_TESTDUMMY, | ||
| DEPLOYMENT_V24, // Deployment of doubling withdrawal limit, extended addresses | ||
| DEPLOYMENT_EVO_SHARES, // Deployment of EvoNode shared collateral and multiple owner payouts | ||
| DEPLOYMENT_TAPROOT, // Deployment of Taproot (BIP 340, 341, 342) outputs and tapscript | ||
| // NOTE: Also add new deployments to VersionBitsDeploymentInfo in deploymentinfo.cpp | ||
| MAX_VERSION_BITS_DEPLOYMENTS | ||
|
Comment on lines
+47
to
49
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
🔴 Blocking: Update the snapshot regression fixture for the additional deployment Adding DEPLOYMENT_TAPROOT raises MAX_VERSION_BITS_DEPLOYMENTS from three to four, but evo_snapshot_tests.cpp:1192-1199 constructs exactly four historical MNHF signals and requires their count to exceed that enum value. The linux64-build, linux64_nowallet-build, and win64-build jobs now fail deterministically with source:
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. addressed as own PR: #8150
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for linking the follow-up PR. That is the appropriate fix, but this head still has only four signals while The finding stands on this commit until that change is pushed; the push gets a full review.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved (re-reviewed at |
||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,7 +73,7 @@ bool IsStandard(const CScript& scriptPubKey, const std::optional<unsigned>& max_ | |
| return true; | ||
| } | ||
|
|
||
| bool IsStandardTx(const CTransaction& tx, const std::optional<unsigned>& max_datacarrier_bytes, bool permit_bare_multisig, const CFeeRate& dust_relay_fee, std::string& reason) | ||
| bool IsStandardTx(const CTransaction& tx, const std::optional<unsigned>& max_datacarrier_bytes, bool permit_bare_multisig, const CFeeRate& dust_relay_fee, bool taproot_active, std::string& reason) | ||
| { | ||
| if (tx.nVersion > TX_MAX_STANDARD_VERSION || tx.nVersion < 1) { | ||
| reason = "version"; | ||
|
|
@@ -130,6 +130,10 @@ bool IsStandardTx(const CTransaction& tx, const std::optional<unsigned>& max_dat | |
| reason = "scriptpubkey"; | ||
| return false; | ||
| } | ||
| if (whichType == TxoutType::TAPROOT && !taproot_active) { | ||
| reason = "scriptpubkey"; | ||
| return false; | ||
| } | ||
|
|
||
| if (whichType == TxoutType::NULL_DATA) | ||
| nDataOut++; | ||
|
|
@@ -167,7 +171,7 @@ bool IsStandardTx(const CTransaction& tx, const std::optional<unsigned>& max_dat | |
| * expensive-to-check-upon-redemption script like: | ||
| * DUP CHECKSIG DROP ... repeated 100 times... OP_1 | ||
| */ | ||
| bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs) | ||
| bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs, bool taproot_active) | ||
| { | ||
| if (tx.IsCoinBase()) | ||
| return true; // Coinbases don't use vin normally | ||
|
|
@@ -198,6 +202,49 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs) | |
| if (subscript.GetSigOpCount(true) > MAX_P2SH_SIGOPS) { | ||
| return false; | ||
| } | ||
| } else if (whichType == TxoutType::TAPROOT) { | ||
| // Don't allow Taproot spends unless Taproot is active. | ||
| if (!taproot_active) return false; | ||
| } | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| bool IsTaprootStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs) | ||
| { | ||
| if (tx.IsCoinBase()) | ||
| return true; // Coinbases are skipped | ||
|
|
||
| for (unsigned int i = 0; i < tx.vin.size(); i++) | ||
| { | ||
| const CTxOut& prev = mapInputs.AccessCoin(tx.vin[i].prevout).out; | ||
| if (!prev.scriptPubKey.IsPayToTaproot()) continue; | ||
|
|
||
| std::vector<std::vector<unsigned char>> stack_items; | ||
| if (!ParseTaprootStack(tx.vin[i].scriptSig, stack_items)) return false; | ||
| Span<const std::vector<unsigned char>> stack{stack_items}; | ||
|
Comment on lines
+224
to
+226
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
🔴 Blocking: Require canonical scriptSig pushes for standard Taproot spends ParseTaprootStack accepts nonminimal push encodings, while VerifyScript returns through the Taproot path before the legacy interpreter can enforce SCRIPT_VERIFY_MINIMALDATA. IsStandardTx only requires push-only scriptSig, and this policy check does not restore minimal-push enforcement. A third party can change a key-path spend from source:
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved (re-reviewed at |
||
| if (stack.size() >= 2 && !stack.back().empty() && stack.back()[0] == ANNEX_TAG) { | ||
| // Annexes are nonstandard as long as no semantics are defined for them. | ||
| return false; | ||
| } | ||
| if (stack.size() >= 2) { | ||
| // Script path spend (2 or more stack elements after removing optional annex) | ||
| const auto& control_block = SpanPopBack(stack); | ||
| SpanPopBack(stack); // Ignore script | ||
| if (control_block.empty()) return false; // Empty control block is invalid | ||
| if ((control_block[0] & TAPROOT_LEAF_MASK) == TAPROOT_LEAF_TAPSCRIPT) { | ||
| // Leaf version 0xc0 (aka Tapscript, see BIP 342) | ||
| for (const auto& item : stack) { | ||
| if (item.size() > MAX_STANDARD_TAPSCRIPT_STACK_ITEM_SIZE) return false; | ||
| } | ||
| } | ||
| } else if (stack.size() == 1) { | ||
| // Key path spend (1 stack element after removing optional annex) | ||
| // (no policy rules apply) | ||
| } else { | ||
| // 0 stack elements; this is already invalid by consensus rules | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
|
|
||
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.
Keep the suite-wide failure timeout bounded.
If a functional test waits for a condition that never occurs, the new default turns a 60-second wait into 40 minutes. CI forwards this factor to every test and permits three attempts, so a failed condition can delay diagnosis for hours. Keep the lower suite-wide default and increase the factor only for tests that need it. (raw.githubusercontent.com)