Repository navigation
fix(compile): compile only for the requested script context - #317
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #317 +/- ##
==========================================
+ Coverage 61.14% 61.43% +0.28%
==========================================
Files 23 23
Lines 4002 3993 -9
==========================================
+ Hits 2447 2453 +6
+ Misses 1555 1540 -15
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
c626394 to
eb8ca3f
Compare
eb8ca3f to
6ed624e
Compare
6ed624e to
85a7144
Compare
|
ACK 6ed624e
|
85a7144 to
6e64d8f
Compare
Thanks for testing!
Added the
On |
Musab1258
left a comment
There was a problem hiding this comment.
re-ACK 6e64d8f
I re-reviewed after the rebase and force-push. git range-diff shows the fix in src/handlers/descriptor.rs is unchanged; only the commit message, the CHANGELOG context, and the test differ. I confirmed the test, which has been renamed to test_compile_policy_beyond_legacy_limits, now covers tr and wsh. I ran the new test, and it passed.
I also confirmed that bdk-cli resolves miniscript 12.3.7 via bdk_wallet 3.1.0. PR #828 removes the .expect("Terminal creation must always succeed") in the compiler's terminal construction, which matches the panic location.
There was a problem hiding this comment.
ACK 6e64d8f
Thanks for working on this @vadim-anfv .
While this addresses the issue stated in the PR description, it opens up a question (from the test) that we might investigate in another issue. Whether compile accepts non-key policies and generate invalid descriptors.
NIT: In the PR description, the statement "CHECKMULTISIG takes at most 15 keys" seemed incorrect. Maximum pubkeys per CHECKMULTISIG is 20 (check here). For sh, the redeem script is pushed as a single script element and must stay under 520 bytes (i.e at most 15 compressed keys). P2WSH can still use CHECKMULTISIG up to 20 keys.
|
Also, kindly rebase to fix the CHANGELOG confict. |
Compiling for all three contexts let the narrowest one reject a policy that is valid for the requested type: a 9-of-16 multisig, fine as taproot multi_a, failed even for --type tr because legacy hit the 520-byte consensus limit on script elements. The same policy also panicked for --type wsh, which the test now covers.
6e64d8f to
eadbdc7
Compare
|
Thanks for the review @tvpeter!
Agreed, that was worded sloppily, I meant the sh limit, not and 16 keys don't:
Yes, we already touched on it in #225. I have an idea for this, I'll open an issue with a proposed solution.
Done! |
The policy is compiled for all three script contexts one after another, before
--typeis looked at, and any of those failing aborts the command. So a policy that is valid for the type you asked for is rejected because it is invalid for one of the other two.Here a 9-of-16 multisig is compiled with
--type trand fails on the sh limit: 16 keys don't fit intoMAX_SCRIPT_ELEMENT_SIZE, the 520-byte consensus limit for the sh redeem script. Taproot has no such limit.The fix moves the compilation into the matching branch, so only the requested context is compiled.
Changelog notice
compilerejecting policies that are valid for the requested script typeChecklists
All Submissions:
cargo fmtandcargo clippybefore committingBugfixes: