fix(tbtcpg): price P2TR redeemer output scripts - #4244
Open
piotr-roslaniec wants to merge 1 commit into
Open
Conversation
The redeemer-script switch in EstimateRedemptionFee has no P2TR arm, so a P2TR redeemer output script falls through to the non-standard default and returns an error. That aborts the fee estimate for the whole batch, so one P2TR request stalls every pending redemption for that wallet rather than only its own. The Bridge accepts P2TR redeemer addresses (Redemption.sol validates against a set that includes them), so this is reachable as soon as a redeemer supplies one. Price it with AddOutputScript rather than a dedicated helper: an output costs its script length plus a fixed header, and the real script is already in hand, so no canonical placeholder is needed. The default arm still rejects genuinely non-standard scripts and now names the type it rejected.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #4243, which supplies the
P2TRScripthandling inpkg/bitcoin/estimator.gothis needs. Retarget tomainonce #4243 lands.The bug
EstimateRedemptionFee's redeemer-script switch has no P2TR arm, so a P2TRredeemer output script falls through to the non-standard
defaultand returnsan error. That error aborts the estimate for the entire batch, so one P2TR
request stalls every pending redemption for that wallet, not just its own.
The Bridge accepts P2TR redeemer addresses --
Redemption.solvalidatesagainst a set that includes them -- so this is reachable as soon as any
redeemer supplies one.
This switch is byte-identical on
main, so the gap predates the FROST work andis not introduced by #3866.
The fix
Add the arm using
AddOutputScript. An output costs its script length plus afixed header, and the real script is already in hand, so there is no need for a
canonical placeholder the way the P2PKH and P2SH arms use one.
The
defaultarm still rejects genuinely non-standard scripts, and now namesthe type it rejected -- previously the error gave an operator no way to identify
the offending request.
Testing
Two new tests: a batch containing a P2TR redeemer must be priced and must cost
strictly more than the same batch without it (an equal fee would mean the script
was silently dropped and every redemption in the batch underpaid), and an
OP_RETURN script must still be rejected with its type named.
Verified the first test fails without the fix: